How to set the foreground of DatePicker for disabled state?
I have try set style res:
<SolidColorBrush x:Key="DatePickerForegroundThemeBrush" Color="#444444" />
and:
dpDate.IsEnabled = false;
dpDate.Foreground = new SolidColorBrush(Colors.Black);
but it still transparent.
You need to modify template of the DatePicker control in order to change it's behavior when it is in disabled visual state; actually, there is a button inside the DatePicker and you need to change behavior of that button.
XAML:
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonDisabledForegroundThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"
Storyboard.TargetName="Border">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonDisabledBorderThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
Storyboard.TargetName="Border">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonDisabledBackgroundThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
For a more explained example on customizing control templates, checkout Quickstart: Control templates (XAML).