feat: add demo, fix clear button of TimeRangePicker.
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
Margin="8,0"
|
||||
Content="{DynamicResource TimePickerIconGlyph}"
|
||||
Focusable="False"
|
||||
IsVisible="{Binding !#ClearButton.IsVisible}"
|
||||
Theme="{DynamicResource InnerIconButton}" />
|
||||
</Grid>
|
||||
<Popup
|
||||
@@ -164,11 +165,8 @@
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^.clearButton, ^.ClearButton">
|
||||
<Style Selector="^:pointerover /template/ Button#ClearButton">
|
||||
<Setter Property="IsVisible" Value="{Binding $parent[u:TimePicker].SelectedTime, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
</Style>
|
||||
<Style Selector="^:pointerover /template/ Button#PART_Button">
|
||||
<Setter Property="IsVisible" Value="{Binding $parent[u:TimePicker].SelectedTime, Converter={x:Static ObjectConverters.IsNull}}" />
|
||||
<Style Selector="^:not(:empty):pointerover /template/ Button#ClearButton">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Ursa.Controls;
|
||||
[TemplatePart(PART_StartPresenter, typeof(TimePickerPresenter))]
|
||||
[TemplatePart(PART_EndPresenter, typeof(TimePickerPresenter))]
|
||||
[TemplatePart(PART_Button, typeof(Button))]
|
||||
[PseudoClasses(PseudoClassName.PC_Empty)]
|
||||
public class TimeRangePicker : TimePickerBase, IClearControl
|
||||
{
|
||||
public const string PART_StartTextBox = "PART_StartTextBox";
|
||||
@@ -92,6 +93,8 @@ public class TimeRangePicker : TimePickerBase, IClearControl
|
||||
public void Clear()
|
||||
{
|
||||
Focus(NavigationMethod.Pointer);
|
||||
SetCurrentValue(StartTimeProperty, null);
|
||||
SetCurrentValue(EndTimeProperty, null);
|
||||
_startPresenter?.SyncTime(null);
|
||||
_endPresenter?.SyncTime(null);
|
||||
}
|
||||
@@ -120,10 +123,10 @@ public class TimeRangePicker : TimePickerBase, IClearControl
|
||||
textBox.Text = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var date = new DateTime(1, 1, 1, time.Value.Hours, time.Value.Minutes, time.Value.Seconds);
|
||||
var text = date.ToString(DisplayFormat);
|
||||
textBox.Text = text;
|
||||
PseudoClasses.Set(PseudoClassName.PC_Empty, StartTime is null && EndTime is null);
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user