Skip to content

Make TimePicker Icon-Button hidable #3663

Closed

Description

@SiggiSch

It would be nice to hide the Clock-Button of the TimePicker control whenever I want to. For example I would like to hide the button, when the TimePicker is disabled. I could define a binding for that or just hide the button indefinitely.

Maybe with a dependency Property "bool HidePopupButton" or "Visibility HidePopupButton". So that I could use it like this:

<TimePicker HidePopupButton="True" />
or
<TimePicker HidePopupButton="{Binding IsEnabled, RelativeSource={RelativeSource Self}, Converter={StaticResource InvertBooleanConverter}}" />

We have similar controls in our project, where the button is hidden, when the control is disabled. With the TimePicker we want to have the same behaviour.

Activity

  1. nicolaihenriksen commented on Sep 4, 2024

    @nicolaihenriksen
    Contributor

    @SiggiSch Assuming you don't have any other Buttons added to the content of the TimePicker (where this behavior is not desirable), you should be able to add the resource below which simply amends the button style with a trigger that hides a button when TimePicker.IsEnabled=False.

    <materialDesign:TimePicker materialDesign:HintAssist.HelperText="Helper text"
                               materialDesign:HintAssist.Hint="Pick Time"
                               Is24Hours="True"
                               IsEnabled="False"
                               Style="{StaticResource MaterialDesignOutlinedTimePicker}">
      <materialDesign:TimePicker.Resources>
        <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
          <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
              <Setter Property="Visibility" Value="Hidden" />
            </Trigger>
          </Style.Triggers>
        </Style>
      </materialDesign:TimePicker.Resources>
    </materialDesign:TimePicker>

    image

  2. SiggiSch commented on Sep 6, 2024

    @SiggiSch
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions