【问题标题】:How to change the icon of the WPF datepicker?如何更改 WPF 日期选择器的图标?
【发布时间】:2012-12-11 16:54:01
【问题描述】:

我正在做一个 wpf 应用程序,其中我的应用程序中有两个日期选择器。我想知道是否有任何快速的方法(比如我设置日期选择器背景的方式)来更改 wpf 默认日期选择器的日历图标?

我的日期选择器代码 sn-p:

  <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>

我的日期选择器:

【问题讨论】:

    标签: wpf datepicker


    【解决方案1】:

    我认为你应该使用自己的风格。见DatePicker Style

    您所指的图标是样式的这一部分:

    <Path HorizontalAlignment="Center" Margin="4,3,4,3" ...
    <Ellipse HorizontalAlignment="Center" ...
    <Border Grid.ColumnSpan="4" Grid.Row="0" Grid.RowSpan="4" ...
    

    【讨论】:

    • 找不到 xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 和 xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows .Controls"....我需要添加哪些引用?
    • @0070 它写在那里;在Default Style and Template 下: xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    猜你喜欢
    • 2016-09-03
    • 2020-02-06
    • 1970-01-01
    • 1970-01-01
    • 2020-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多