如何更改 WPF 日期选择器的图标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14035379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change the icon of the WPF datepicker?
提问by 0070
I'm doing a wpf application where i have two datepicker inside my application. I want to know is that any quick way(like the way i set my datepicker background) for me to change the calendar icon of the wpf default datepicker?
我正在做一个 wpf 应用程序,其中我的应用程序中有两个日期选择器。我想知道有什么快速的方法(比如我设置日期选择器背景的方式)让我更改 wpf 默认日期选择器的日历图标?
my datepicker code snippet:
我的日期选择器代码片段:
<DatePicker Name="datefromDP" Width="100" Height="24"Foreground="White" BorderThickness="0" >
<DatePicker.Resources>
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="Text" Value="Select date" />
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BeaconProject;component/B_images/button/loginheader_bg.jpg"/>
</Setter.Value>
</Setter>
</Style>
</DatePicker.Resources>
</DatePicker>
my datepicker:
我的日期选择器:


回答by Ramin
I think you should Use your own style. see DatePicker Style.
我认为你应该使用自己的风格。请参阅日期选择器样式。
The Icon you are referring to is this part of the style:
您所指的图标是样式的这一部分:
<Path HorizontalAlignment="Center" Margin="4,3,4,3" ...
<Ellipse HorizontalAlignment="Center" ...
<Border Grid.ColumnSpan="4" Grid.Row="0" Grid.RowSpan="4" ...

