WPF DatePickerTextBox- change font color / opacity when IsEnabled == false
I'm having a hard time trying to style myself out of the problem specified in the title. Has anyone here done that?
When the DatePicker
control is disabled the font o开发者_Python百科n the DatePickerTextBox
is gray and hard to read. I'm changing to change that.
Regards, Fredrik.
You'll want to look into the SystemColors class... In the resources for a given control, you can override one of those colors by specifying a Brush. For example:
<Brush x:Key="{x:Static SystemColors.GrayTextBrushKey}" Color="Black"/>
The enabled-ness of a DatePicker
is controlled using a semi-opaque overlay in its control template called PART_DisabledVisual
. Your only real option is to re-style the whole DatePicker
ControlTemplate
using Expression Blend or ShowMeTheTemplate or MSDN and change these lines:
<Rectangle Grid.Row="0" Grid.Column="0" RadiusX="1" RadiusY="1" Fill="#A5FFFFFF"/>
<Rectangle Grid.Row="0" Grid.Column="1" RadiusX="1" RadiusY="1" Fill="#A5FFFFFF" Height="18" Width="19" Margin="3,0,3,0" />
to this:
<Rectangle Grid.Column="0" Fill="Transparent" RadiusY="1" Grid.Row="0" RadiusX="1"/>
<Rectangle Grid.Column="1" Fill="Transparent" Height="18" Margin="3,0,3,0" RadiusY="1" Grid.Row="0" RadiusX="1" Width="19"/>
which will stop the overlay from graying out the TextBox
. What to do instead when disabled, if anything, is then up to you.
精彩评论