Skip to content

Commit ab65856

Browse files
authored
added "ClockButtonVisibility" property to TimePicker (#3664)
1 parent 66965c3 commit ab65856

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

src/MainDemo.Wpf/Pickers.xaml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,31 @@
213213
</smtx:XamlDisplay>
214214
</StackPanel>
215215

216-
<smtx:XamlDisplay Margin="0,16,0,0"
217-
HorizontalAlignment="Left"
218-
VerticalAlignment="Top"
219-
UniqueKey="pickers_7">
220-
<materialDesign:TimePicker x:Name="PresetTimePicker"
221-
Width="100"
222-
Is24Hours="True"
223-
SelectedTimeChanged="PresetTimePicker_SelectedTimeChanged" />
224-
</smtx:XamlDisplay>
216+
<StackPanel>
217+
<smtx:XamlDisplay Margin="0,16,0,0"
218+
HorizontalAlignment="Left"
219+
VerticalAlignment="Top"
220+
UniqueKey="pickers_7">
221+
<materialDesign:TimePicker x:Name="PresetTimePicker"
222+
Width="100"
223+
Is24Hours="True"
224+
SelectedTimeChanged="PresetTimePicker_SelectedTimeChanged" />
225+
</smtx:XamlDisplay>
226+
227+
<smtx:XamlDisplay Margin="0,16,0,0"
228+
HorizontalAlignment="Left"
229+
VerticalAlignment="Top"
230+
UniqueKey="pickers_15">
231+
<materialDesign:TimePicker ClockButtonVisibility="{Binding IsChecked, ElementName=IsClockButtonVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
232+
Width="100"
233+
Is24Hours="True" />
234+
</smtx:XamlDisplay>
235+
<CheckBox x:Name="IsClockButtonVisible"
236+
Margin="0,10,0,0"
237+
VerticalAlignment="Top"
238+
Content="Show clock button" />
239+
</StackPanel>
240+
225241

226242
<StackPanel HorizontalAlignment="Left"
227243
VerticalAlignment="Top">

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TimePicker.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<!-- 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 -->
121121
<Button x:Name="PART_Button"
122122
Height="16"
123+
Visibility="{TemplateBinding ClockButtonVisibility}"
123124
Margin="{TemplateBinding Padding, Converter={StaticResource PartButtonMarginConverter}}"
124125
HorizontalAlignment="Right"
125126
VerticalAlignment="Center"

src/MaterialDesignThemes.Wpf/TimePicker.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ public bool Is24Hours
170170
public static readonly DependencyProperty IsHeaderVisibleProperty = DependencyProperty.Register(
171171
nameof(IsHeaderVisible), typeof(bool), typeof(TimePicker), new PropertyMetadata(default(bool)));
172172

173+
public Visibility ClockButtonVisibility
174+
{
175+
get => (Visibility)GetValue(ClockButtonVisibilityProperty);
176+
set => SetValue(ClockButtonVisibilityProperty, value);
177+
}
178+
179+
public static readonly DependencyProperty ClockButtonVisibilityProperty =
180+
DependencyProperty.Register(nameof(ClockButtonVisibility), typeof(Visibility), typeof(TimePicker), new PropertyMetadata(Visibility.Visible));
181+
173182
public bool IsHeaderVisible
174183
{
175184
get => (bool)GetValue(IsHeaderVisibleProperty);

0 commit comments

Comments
 (0)