зеркало из https://github.com/DeGsoft/maui-linux.git
Implement Time property in WinUI TimePickerHandler
This commit is contained in:
Родитель
fc90bf6c40
Коммит
d9972a73dc
|
@ -161,6 +161,7 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
|
|||
_fontApplied = true;
|
||||
}
|
||||
|
||||
[PortHandler]
|
||||
void UpdateTime()
|
||||
{
|
||||
Control.Time = Element.Time;
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
using System;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.Maui.Handlers
|
||||
{
|
||||
public partial class TimePickerHandler : ViewHandler<ITimePicker, Microsoft.UI.Xaml.Controls.TimePicker>
|
||||
public partial class TimePickerHandler : ViewHandler<ITimePicker, TimePicker>
|
||||
{
|
||||
protected override Microsoft.UI.Xaml.Controls.TimePicker CreateNativeView() => new Microsoft.UI.Xaml.Controls.TimePicker();
|
||||
protected override TimePicker CreateNativeView() => new TimePicker();
|
||||
|
||||
[MissingMapper]
|
||||
public static void MapFormat(TimePickerHandler handler, ITimePicker view) { }
|
||||
|
||||
[MissingMapper]
|
||||
public static void MapTime(TimePickerHandler handler, ITimePicker view) { }
|
||||
public static void MapTime(TimePickerHandler handler, ITimePicker timePicker)
|
||||
{
|
||||
handler.NativeView?.UpdateTime(timePicker);
|
||||
}
|
||||
|
||||
[MissingMapper]
|
||||
public static void MapCharacterSpacing(TimePickerHandler handler, ITimePicker view) { }
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.Maui
|
||||
{
|
||||
public static class TimePickerExtensions
|
||||
{
|
||||
public static void UpdateTime(this TimePicker nativeTimePicker, ITimePicker timePicker)
|
||||
{
|
||||
nativeTimePicker.Time = timePicker.Time;
|
||||
|
||||
if (timePicker.Format?.Contains('H') == true)
|
||||
{
|
||||
nativeTimePicker.ClockIdentifier = "24HourClock";
|
||||
}
|
||||
else
|
||||
{
|
||||
nativeTimePicker.ClockIdentifier = "12HourClock";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче