system.windows.datepicker 更改标题背景颜色
我一直在尝试更改 wpf 默认日期选择器的背景颜色。现在它是深蓝色和黑色文本,客户希望将其更改为白色。我已经写了很多代码,但似乎没有任何效果。
请帮忙。谢谢
<Style x:Key="DateStyle" TargetType="{x:Type DatePcker}" BasedOn="{x:Null}">
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="Yellow" />
</Trigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
<Setter Property="Background" Value="Transparent" />
<Setter Property="CharacterCasing" Value="Upper"/>
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="11" />
</Style>
这是我的日期选择器
<DatePicker Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="4" Height="25" HorizontalAlignment="Left" TabIndex="3"
Name="dpFillingDateFrom" VerticalAlignment="Center" Width="97" Text="12/12/2011" SelectedDateFormat="Short"/>
I have been trying to change the background color of wpf's default datepicker. Right now it is dark blue with black text and client wants it changed to white. I have been coding a lot and nothing seems to work.
Pls help. thanks
<Style x:Key="DateStyle" TargetType="{x:Type DatePcker}" BasedOn="{x:Null}">
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="Yellow" />
</Trigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
<Setter Property="Background" Value="Transparent" />
<Setter Property="CharacterCasing" Value="Upper"/>
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="11" />
</Style>
here's my datepicker
<DatePicker Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="4" Height="25" HorizontalAlignment="Left" TabIndex="3"
Name="dpFillingDateFrom" VerticalAlignment="Center" Width="97" Text="12/12/2011" SelectedDateFormat="Short"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需浏览 http://msdn.microsoft.com/en-us/magazine/ dd882520.aspx。
更改 wpf 默认日期选择器的背景颜色并不直接,但您可以按照以下步骤操作
1)日期选择器有一个 CalenderStye 属性,因此覆盖 Calender 默认 ControlTemplate
2)在 Calender 控件模板中,有 CalenderItemStyle 您可以在其中覆盖 CalenderItemStyle 默认模板。在这里您可以自定义背景颜色以及标题按钮。
Just go through http://msdn.microsoft.com/en-us/magazine/dd882520.aspx.
Its not straight forward to change the background color of wpf's default datepicker but you can follow below steps
1) Date picker has a CalenderStye Property so override Calender Default ControlTemplate
2) In Calender control template, there is CalenderItemStyle where you can override CalenderItemStyle defaulttemplate. In this you can customize the background colors as well as header buttons.