更改WPF中MaterialDesign DatePicker内部文本框“鼠标悬停”颜色

nnsrf1az  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(141)

我可以更改DatePicker的TextBox下划线和日历图标颜色吗?
如下图所示:
enter image description here

<DatePicker materialDesign:HintAssist.Hint="Start Date" Margin="0,25,0,0"
                                                materialDesign:TextFieldAssist.UnderlineBrush="{StaticResource MainThemeColor3}">
                                        <DatePicker.CalendarStyle>
                                            <Style TargetType="Calendar" BasedOn="{StaticResource MaterialDesignCalendarPortrait}">
                                                <Style.Resources>
                                                    <SolidColorBrush x:Key="PrimaryHueMidBrush" Color="{StaticResource secondaryBackColor1}"/>
                                                    <SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="{StaticResource secondaryBackColor2}"/>
                                                </Style.Resources>
                                            </Style>
                                        </DatePicker.CalendarStyle>
                                    </DatePicker>

字符串
我试过这样,但这只能改变颜色后,点击和聚焦一个。
enter image description here
您可以看到图标的颜色仍然没有改变。
我怎么能改变它?

wgxvkvu9

wgxvkvu91#

您应该覆盖DatePickerPrimaryHueMidBrush以更改图标的颜色:

<DatePicker materialDesign:HintAssist.Hint="Start Date" Margin="0,25,0,0"
            materialDesign:TextFieldAssist.UnderlineBrush="{StaticResource MainThemeColor3}">
    <DatePicker.Resources>
        <SolidColorBrush x:Key="PrimaryHueMidBrush" Color="Red" />
    </DatePicker.Resources>
    <DatePicker.CalendarStyle>
        <Style TargetType="Calendar" BasedOn="{StaticResource MaterialDesignCalendarPortrait}">
            <Style.Resources>
                <SolidColorBrush x:Key="PrimaryHueMidBrush" Color="{StaticResource secondaryBackColor1}"/>
                <SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="{StaticResource secondaryBackColor2}"/>
            </Style.Resources>
        </Style>
    </DatePicker.CalendarStyle>
</DatePicker>

字符串

相关问题