Reputation: 19702
The silverlight datepicker can zoom out to allow a user to select by year, but for some reason the first and last years always look disabled. Is there a way to prevent this?
Upvotes: 2
Views: 489
Reputation: 189495
This is one of the many places where the color and style of elements are hardcoded into their default templates. Hence to change the appearance of these "inactive" calendar buttons you need to define a new template.
First you need to create a copy of the controlsPrivitives:CalendarButton
style, you can get a copy of the style from Calendar Styles and Templates. Place this in the Resources
for your user control or even in your App.Xaml. You'll need to copy the namespace aliases also listed in that MSDN topic.
Now you have your own implicit style for the calendar button that you can modify. You'll note the template in that xaml has this visual state group:-
<vsm:VisualStateGroup x:Name="ActiveStates">
<vsm:VisualStateGroup.Transitions>
<vsm:VisualTransition GeneratedDuration="0" />
</vsm:VisualStateGroup.Transitions>
<vsm:VisualState x:Name="Active" />
<vsm:VisualState x:Name="Inactive">
<Storyboard>
<ColorAnimation Storyboard.TargetName="Content" Storyboard.TargetProperty="(ContentControl.Foreground).(SolidColorBrush.Color)" To="#FF777777" Duration="0" />
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
Those years outside of the range are set to the Inactive state and therefore have the hard coded grey color you see in the Inactive state above. So tweak this xaml to your preference.
If you want the same for day buttons you should note that these have a different control CalendarDayButton
so you'll need to do the same exercise on its default style.
Upvotes: 2