Search code examples
c#silverlighttoolkit

How to hide or disable the TimeHint in a toolkit TimeUpDown control in Silverlight?


I looked on the internet but I can find this nowhere : I would like to disable the TimeHint popup that shows the current time when entering focus on a TimeUpDown control. Something like : <12:42AM>

There is no TimeHintEnabled property, nor any kind of member that seems to control this. There is a TimeHintContent property, but it is readonly and seems empty at first.

My code is really simple :

<Grid x:Name="LayoutRoot" Background="Transparent">
    <toolkit:TimeUpDown Name="timeUpDown1"
                        Background="White"
                        Height="22"
                        MinWidth="55"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top" />
</Grid>

Maybe playing with the Template can do the trick, but I don't know how to do it...


Solution

  • Alright, thanks to Blend I found what I was looking for.
    The Template can be easily modified by Blend, this part of the template is needed inside the xaml to hide the TimeHintPopup :

    <Grid>
      <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="TimeHintStates">
          <VisualState x:Name="TimeHintOpenedUp">
            <Storyboard>
              <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"
                                             Storyboard.TargetProperty="Visibility"
                                             Storyboard.TargetName="TimeHintVisualElement">
                <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Collapsed"/>
              </ObjectAnimationUsingKeyFrames>
            </Storyboard>
          </VisualState>
        </VisualStateGroup>
      </VisualStateManager.VisualStateGroups>
    </Grid>
    

    And your TimeUpDown should refer to this template :

        <toolkit:TimeUpDown Name="timeUpDown1" Background="White" Height="22" MinWidth="55" HorizontalAlignment="Left" VerticalAlignment="Top" Style="{StaticResource TimeUpDownStyle1}" />