Yair Briones
Yair Briones

Reputation: 41

Change the appearence of the MaterialDesign DatePicker in WPF

I'm using WPF

Is it possible to edit the entire template for the DatePicker? I want to change some colors but I cannot find where this properties are

I've tried using the next code, but it only changes the container where the date shows, and I also want to change colors from the textbox, the hover day, etc.

<DatePicker>
            <DatePicker.CalendarStyle>
                <Style TargetType="Calendar" BasedOn="{StaticResource MaterialDesignCalendarPortrait}">
                    <Style.Resources>
                        <SolidColorBrush x:Key="PrimaryHueMidBrush" Color="#373A6B" />
                    </Style.Resources>
                </Style>
            </DatePicker.CalendarStyle>
        </DatePicker>

DatePicker

DatePicker W/style

thank you beforehand:)

How can I change the colors?

Upvotes: 0

Views: 4275

Answers (1)

mm8
mm8

Reputation: 169320

Is it possible to edit the entire template for the DatePicker?

Sure. You could copy the original one into your XAML markup and edit it as per your requirements.

Looking at how the templates are defined, you'll see that they refer to resources that you can override. The mouse over brush is for example defined by the PrimaryHueDarkBrush:

<DatePicker>
    <DatePicker.CalendarStyle>
        <Style TargetType="Calendar" BasedOn="{StaticResource MaterialDesignCalendarPortrait}">
            <Style.Resources>
                <SolidColorBrush x:Key="PrimaryHueMidBrush" Color="Red" />
                <SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="Green" />
            </Style.Resources>
        </Style>
    </DatePicker.CalendarStyle>
</DatePicker>

Upvotes: 2

Related Questions