Skip to content

Commit

Permalink
added "ClockButtonVisibility" property to TimePicker (MaterialDesignI…
Browse files Browse the repository at this point in the history
  • Loading branch information
corvinsz authored Sep 5, 2024
1 parent 66965c3 commit ab65856
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/MainDemo.Wpf/Pickers.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,31 @@
</smtx:XamlDisplay>
</StackPanel>

<smtx:XamlDisplay Margin="0,16,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
UniqueKey="pickers_7">
<materialDesign:TimePicker x:Name="PresetTimePicker"
Width="100"
Is24Hours="True"
SelectedTimeChanged="PresetTimePicker_SelectedTimeChanged" />
</smtx:XamlDisplay>
<StackPanel>
<smtx:XamlDisplay Margin="0,16,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
UniqueKey="pickers_7">
<materialDesign:TimePicker x:Name="PresetTimePicker"
Width="100"
Is24Hours="True"
SelectedTimeChanged="PresetTimePicker_SelectedTimeChanged" />
</smtx:XamlDisplay>

<smtx:XamlDisplay Margin="0,16,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
UniqueKey="pickers_15">
<materialDesign:TimePicker ClockButtonVisibility="{Binding IsChecked, ElementName=IsClockButtonVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
Width="100"
Is24Hours="True" />
</smtx:XamlDisplay>
<CheckBox x:Name="IsClockButtonVisible"
Margin="0,10,0,0"
VerticalAlignment="Top"
Content="Show clock button" />
</StackPanel>


<StackPanel HorizontalAlignment="Left"
VerticalAlignment="Top">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
<!-- VerticalAlignment=Center to follow the default ComboBox style where the arrow is always vertically centered. Could be problematic to try to calculate the offset because it needs to be v-centered in relation to the content of the nested TextBox -->
<Button x:Name="PART_Button"
Height="16"
Visibility="{TemplateBinding ClockButtonVisibility}"
Margin="{TemplateBinding Padding, Converter={StaticResource PartButtonMarginConverter}}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Expand Down
9 changes: 9 additions & 0 deletions src/MaterialDesignThemes.Wpf/TimePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ public bool Is24Hours
public static readonly DependencyProperty IsHeaderVisibleProperty = DependencyProperty.Register(
nameof(IsHeaderVisible), typeof(bool), typeof(TimePicker), new PropertyMetadata(default(bool)));

public Visibility ClockButtonVisibility
{
get => (Visibility)GetValue(ClockButtonVisibilityProperty);
set => SetValue(ClockButtonVisibilityProperty, value);
}

public static readonly DependencyProperty ClockButtonVisibilityProperty =
DependencyProperty.Register(nameof(ClockButtonVisibility), typeof(Visibility), typeof(TimePicker), new PropertyMetadata(Visibility.Visible));

public bool IsHeaderVisible
{
get => (bool)GetValue(IsHeaderVisibleProperty);
Expand Down

0 comments on commit ab65856

Please sign in to comment.