Reputation: 133
I have the code to override a CalendarDatePicker resource (CalendarDatePickerCalendarGlyphForeground) in XAML.
<CalendarDatePicker Style="{StaticResource CalendarDatePickerStyle}">
<CalendarDatePicker.Resources>
<SolidColorBrush x:Key="CalendarDatePickerCalendarGlyphForeground" Color="{StaticResource PrimaryColor}"/>
</CalendarDatePicker.Resources>
</CalendarDatePicker>
Now, I need reuse this code, creating a generic style in my styles file project, to use in the others CalendarDatePicker in my project, like this:
<Style x:Key="CalendarDatePickerStyle" TargetType="CalendarDatePicker">
<Setter ....
</Style>
How should I do that with a Setter?
And if I wanted to apply a generic style to all project calendars without having to be typing in every Calendar Style={StaticResource ...}, how should I define this style?
Upvotes: 1
Views: 204
Reputation: 12906
You can directly add the SolidColorBrush definition into your App.xaml resources and it will override the default styling. The main thing is to use the same Key as the control uses.
So for example to override CalendarDatePickerCalendarGlyphForeground with your own color in every CalendarDatePicker, make the App.xaml look like the following:
<Application
x:Class="App1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
RequestedTheme="Light">
<Application.Resources>
<SolidColorBrush x:Key="CalendarDatePickerCalendarGlyphForeground" Color="Green"/>
</Application.Resources>
Here more info about styling controls in UWP.
Upvotes: 4