fix: fix panel format change handling.
This commit is contained in:
@@ -11,21 +11,36 @@
|
||||
<StackPanel HorizontalAlignment="Left">
|
||||
<ToggleSwitch Name="needConfirm" Content="Need Confirm" />
|
||||
<TextBlock Text="{Binding #picker.SelectedTime}" />
|
||||
<TextBox
|
||||
Name="displayFormat"
|
||||
Width="300"
|
||||
InnerLeftContent="Display Format"
|
||||
Text="HH 时 mm 分 ss 秒" />
|
||||
<TextBox
|
||||
Name="panelFormat"
|
||||
Width="300"
|
||||
InnerLeftContent="Panel Format"
|
||||
Text="tt HH mm ss" />
|
||||
<u:TimePicker
|
||||
Name="picker"
|
||||
Width="200"
|
||||
HorizontalAlignment="Left"
|
||||
DisplayFormat="{Binding #displayFormat.Text}"
|
||||
NeedConfirmation="{Binding #needConfirm.IsChecked}"
|
||||
PanelFormat="hh mm tt" />
|
||||
PanelFormat="{Binding #panelFormat.Text}" />
|
||||
|
||||
<u:TimePicker
|
||||
Width="300"
|
||||
Classes="ClearButton"
|
||||
DisplayFormat="HH 时 mm 分 ss 秒"
|
||||
PanelFormat="tt HH mm ss"
|
||||
HorizontalAlignment="Left"
|
||||
NeedConfirmation="True"
|
||||
Classes="ClearButton"
|
||||
DisplayFormat="{Binding #displayFormat.Text}"
|
||||
InnerLeftContent="时刻"
|
||||
InnerRightContent="截止" />
|
||||
<u:TimeRangePicker Width="300"></u:TimeRangePicker>
|
||||
InnerRightContent="截止"
|
||||
NeedConfirmation="True"
|
||||
PanelFormat="{Binding #panelFormat.Text}" />
|
||||
<u:TimeRangePicker
|
||||
Width="300"
|
||||
DisplayFormat="{Binding #displayFormat.Text}"
|
||||
PanelFormat="{Binding #panelFormat.Text}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -141,6 +141,8 @@ public class TimePickerPresenter : TemplatedControl
|
||||
foreach (var part in parts)
|
||||
{
|
||||
if (part.Length < 1) continue;
|
||||
try
|
||||
{
|
||||
if ((part.Contains('h') || part.Contains('H')) && !panels.Contains(_hourScrollPanel))
|
||||
{
|
||||
panels.Add(_hourScrollPanel);
|
||||
@@ -168,6 +170,11 @@ public class TimePickerPresenter : TemplatedControl
|
||||
_ampmSelector?.SetValue(DateTimePickerPanel.ItemFormatProperty, part);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (panels.Count < 1) return;
|
||||
IsVisibleProperty.SetValue(false, _hourScrollPanel, _minuteScrollPanel, _secondScrollPanel, _ampmScrollPanel,
|
||||
|
||||
Reference in New Issue
Block a user