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