Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dateonly and timeonly support to pickers. #957

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions controls/datepicker/dateonly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: Date Only Support
page_title: .NET MAUI Date Picker Documentation - Date Only Support
description: Set date only type in the Telerik UI for .NET MAUI DatePicker.
position: 4
slug: datepicker-dateonly
---

# Date Only Support in .NET MAUI DatePicker

The DatePicker has a support for `DateOnly`. You can set a `DateOnly` value to the `MinimumDate`, `MaximumDate`, `Date` and `DefaultHighlightedDate` properties by using the Telerik `DateOnlyToDateTimeConverter `converter. The converter converts `System.DateOnly` to `System.DateTime` and converts back `System.DateTime` to `System.DateOnly`.

Here is the converter definition in XAML:

<snippet id='datepicker-dateonly-to-datetimeconverter' />

The following example demonstrates how to set `DateOnly` in the DatePicker using a converter.

**1.** Define the control and the properties:

<snippet id='datepicker-dateonly-support' />

**2.** Define the converter in the Page's resource:

<snippet id='datepicker-dateonly-to-datetimeconverter' />

**3.** Add the `telerik` namespace:

```XAML
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
```

**4.** Add the `ViewModel`:

<snippet id='datepicker-dateonly-viewmodel' />

## See Also

- [Formatting the Telerik UI for .NET MAUI DatePicker]({%slug datepicker-formatting%})
- [.NET MAUI DatePicker Templates]({%slug datepicker-templates%})
- [.NET MAUI DatePicker Selection]({%slug datepicker-selection%})
- [.NET MAUI DatePicker Styling]({%slug datepicker-styling%})
- [.NET MAUI DatePicker Product Page](https://www.telerik.com/maui-ui/datepicker)
1 change: 1 addition & 0 deletions controls/datepicker/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The Telerik UI for .NET MAUI DatePicker allows you to select a date and visualiz
* [Templates]({%slug datepicker-templates%})&mdash;The DatePicker provides templates for its header and footer as well as exposes templates for its placeholder and display text.
* [Text upon selection]({%slug datepicker-formatting%}#setting-the-closed-dialog-string-format)&mdash;You can set the text that will be displayed when a date is selected by using the `DisplayStringFormat` property of the DatePicker.
* [Date ranges]({%slug datepicker-date-range%})&mdash;You can also define date ranges by setting minimum and maximum date values, and choose a date within that range.
* [DateOnly Support]({%slug datepicker-dateonly%})&mdash;The DatePicker provides a support for DateOnly type using a converter.
* [Flexible styling API]({%slug datepicker-styling%})&mdash;The DatePicker provides a number of styling capabilities, which enable you to style its spinners, popup and popup header and footer, the displayed text displayed after a date is selected, and more.
* [Commands support]({%slug datepicker-commands%})&mdash;The DatePicker exposes commands that allow you to clear the selected date and to open and close the popup.
* [Localization support]({%slug datepicker-localization%})&mdash;Translate the used across the DatePicker text to other languages, so that your app can be adapted to different regions.
Expand Down
2 changes: 2 additions & 0 deletions controls/timepicker/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ The TimePicker provides a number of features which allow you to set a time range

* [Time ranges]({%slug timepicker-time-range%})&mdash;The TimePicker allows you to define a time range by setting minimum and maximum time values and enables users to choose a time within that range.

* [TimeOnly Support]({%slug timepicker-timeonly%})&mdash;The TimePicker provides a support for TimeOnly type using a converter.

* [Spinner format]({%slug timepicker-formatting%}#spinner-format)&mdash;The TimePicker for .NET MAUI allows you to use a standard or a custom time format string through the `TimePicker.SpinnerFormat` property. Depending on the types of the format that is set, the picker visualizes spinner controls with pre-populated values that can be picked.

* [Picker mode]({%slug timepicker-picker-mode%})&mdash;You can choose between `Popup` and `DropDown` UI for showing the spinner controls with the available time values. For Desktop the default picker mode is `DropDown` while for mobile it's `Popup`.
Expand Down
43 changes: 43 additions & 0 deletions controls/timepicker/timeonly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: TimeOnly Support
page_title: .NET MAUI TimePicker Documentation - TimeOnly Support
description: Set date only type in the Telerik UI for .NET MAUI TimePicker.
position: 4
slug: timepicker-timeonly
---

# TimeOnly Support in .NET MAUI TimePicker

The TimePicker has a support for `TimeOnly`. You can set a `TimeOnly` value to the `MinimumTime`, `MaximumTime`, `Time` and `DefaultHighlightedTime` properties by using the Telerik `TimeOnlyToTimeSpanConverter `converter. The converter converts `System.TimeOnly` to `System.TimeSpan` and converts back `System.TimeSpan` to `System.TimeOnly`.

Here is the converter definition in XAML:

<snippet id='timepicker-timeonly-to-timespanconverter' />

The following example demonstrates how to set `TimeOnly` in the TimePicker using a converter.

**1.** Define the TimePicker control and the time properties:

<snippet id='timepicker-timeonly-support' />

**2.** Define the converter in the Page's resource:

<snippet id='timepicker-timeonly-to-timespanconverter' />

**3.** Add the `telerik` namespace:

```XAML
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
```

**4.** Add the `ViewModel`:

<snippet id='timepicker-timeonly-viewmodell' />

## See Also

- [Templates]({%slug timepicker-templates%})
- [Time Format Strings]({%slug timepicker-formatting%})
- [Styling]({%slug timepicker-styling%})
- [Selection]({%slug timepicker-selection%})
- [Commands]({%slug timepicker-commands%})
2 changes: 2 additions & 0 deletions controls/timespanpicker/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The Telerik UI for .NET MAUI TimeSpanPicker provides an easy way to select a tim

* [Time range]({%slug timespanpicker-timespan-range%})&mdash;The TimeSpanPicker allows you to define a time range by setting minimum and maximum time values and enables users to choose a time within that range.

* [TimeOnly Support]({%slug timespanpicker-timeonly%})&mdash;The TimeSpanPicker provides a support for TimeOnly type using a converter.

* [Time interval selection]({%slug timespanpicker-selection%})&mdash;You can set a currently selected time interval to the TimeSpanPicker or define a default highlighted time interval.

* [Incremental time steps]({%slug timespanpicker-timespan-steps%})&mdash;You can also change the default time interval steps to days, hours, minutes, or seconds.
Expand Down
42 changes: 42 additions & 0 deletions controls/timespanpicker/timeonly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: TimeOnly Support
page_title: .NET MAUI TimeSpanPicker Documentation - TimeOnly Support
description: Set date only type in the Telerik UI for .NET MAUI TimeSpanPicker.
position: 4
slug: timespanpicker-timeonly
---

# TimeOnly Support in .NET MAUI TimeSpanPicker

The TimePicker has a support for `TimeOnly`. Set a `TimeOnly` value to the `MinimumTime`, `MaximumTime`, `Time` and `DefaultHighlightedTime` properties by using the Telerik `TimeOnlyToTimeSpanConverter `converter. The converter converts `System.TimeOnly` to `System.TimeSpan` and converts back `System.TimeSpan` to `System.TimeOnly`.

Here is the converter definition in XAML:

<snippet id='timepicker-timeonly-to-timespanconverter' />

The following example demonstrates how to set `TimeOnly` in the TimeSpanPicker using a converter.

**1.** Define the TimeSpanPicker control and the time properties:

<snippet id='timespanpicker-timeonly-support' />

**2.** Define the converter in the Page's resource:

<snippet id='timepicker-timeonly-to-timespanconverter' />

**3.** Add the `telerik` namespace:

```XAML
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
```

**4.** Add the `ViewModel`:

<snippet id='timepicker-timeonly-viewmodell' />

## See Also

- [Templates]({%slug timespanpicker-templates%})
- [Styling]({%slug timespanpicker-styling%})
- [Commands]({%slug timespanpicker-commands%})
- [Selection]({%slug timespanpicker-selection%})