Virang Patel
Virang Patel

Reputation: 103

How do you change the color of the DatePicker control for .NET MAUI

I am using .NET MAUI and i want to change the color of the DatePicker. in Styles.Xaml, it has the following:

<Style TargetType="DatePicker">
    <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
    <Setter Property="FontFamily" Value="OpenSansRegular"/>
    <Setter Property="FontSize" Value="14"/>
    <Setter Property="VisualStateManager.VisualStateGroups">
        <VisualStateGroupList>
            <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal">
                    <VisualState.Setters>
                        <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="Disabled">
                    <VisualState.Setters>
                        <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource LightGray}, Dark={StaticResource DarkGray}}" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateGroupList>
    </Setter>
</Style>

How do I change the default colors of it

Upvotes: 0

Views: 2401

Answers (1)

Volodymyr
Volodymyr

Reputation: 1255

<Style x:Key="DatePickerBackground" TargetType="DatePicker">
    <Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource PrimaryInputControlBackground}, Dark={StaticResource White}}" />
</Style>

Or if you want to chnage it directly:

<Style x:Key="DatePickerBackground" TargetType="DatePicker">
    <Setter Property="BackgroundColor" Value="Red" />
</Style>

Upvotes: -2

Related Questions