Tuesday, November 27, 2018

Truncated month/year in DatePicker

I spent about an hour reading the DatePicker template to figure this out.


As you can see, the month/year label is truncated. Even though it doesn't look like one, this control is a button. Searching through my styles (thank goodness I have them all in one place), I find this style...


<Style TargetType="{x:Type Button}">
    <Setter Property="Margin" Value="1"/>
    <Setter Property="HorizontalAlignment" Value="Right"/>
    <Setter Property="Width" Value="100"/>
    <Setter Property="Height" Value="22"/>
</Style>


This sets the height of all buttons to 22 px by default, including the buttons in the date pickers.


  • I could duplicate the DatePicker template and use a different style for this button. 
  • I could give this style a key and explicitly reference it for all other buttons. 
  • I could set the default height of all buttons to 25 px.



<Style TargetType="{x:Type Button}">
    <Setter Property="Margin" Value="1"/>
    <Setter Property="HorizontalAlignment" Value="Right"/>
    <Setter Property="Width" Value="100"/>
    <Setter Property="Height" Value="25"/>
</Style>



No comments:

Post a Comment