feat: fix display format change in TimeRangePicker.

This commit is contained in:
rabbitism
2024-09-04 02:39:13 +08:00
parent 561554f2bf
commit ea08e040ec
2 changed files with 18 additions and 4 deletions

View File

@@ -12,9 +12,9 @@
mc:Ignorable="d">
<StackPanel HorizontalAlignment="Left">
<ToggleSwitch Name="needConfirm" Content="Need Confirm" />
<!--
<TextBlock Text="{Binding #picker.SelectedTime}" />
-->
<TextBox
Name="displayFormat"
Width="300"
@@ -25,7 +25,7 @@
Width="300"
InnerLeftContent="Panel Format"
Text="tt HH mm ss" />
<!--
<u:TimePicker
Name="picker"
Width="200"
@@ -47,7 +47,7 @@
Width="300"
DisplayFormat="{Binding #displayFormat.Text}"
PanelFormat="{Binding #panelFormat.Text}" />
-->
<TextBlock Text="Binding"/>
<u:TimePicker
Width="300"

View File

@@ -57,8 +57,22 @@ public class TimeRangePicker : TimePickerBase, IClearControl
picker.OnSelectionChanged(args));
EndTimeProperty.Changed.AddClassHandler<TimeRangePicker, TimeSpan?>((picker, args) =>
picker.OnSelectionChanged(args, false));
DisplayFormatProperty.Changed.AddClassHandler<TimeRangePicker, string?>((picker, args) => picker.OnDisplayFormatChanged(args));
}
private void OnDisplayFormatChanged(AvaloniaPropertyChangedEventArgs<string?> args)
{
if (_startTextBox is not null)
{
SyncTimeToText(StartTime);
}
if (_endTextBox is not null)
{
SyncTimeToText(EndTime, false);
}
}
public string? EndWatermark
{
get => GetValue(EndWatermarkProperty);