英文:
Change the inner textbox 'mouse over' color of the MaterialDesign DatePicker in WPF
问题
You can change the DatePicker's TextBox underline and calendar icon color like this:
<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>
This code should change the color of both the TextBox underline and the calendar icon.
英文:
Can i change DatePicker's TextBox underline and calender icon color?
like below :
<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>
I tried like this but this can only change the color after clicked and focused one.
You can see that the icon's color still hasn't changed.
How can i change it?
答案1
得分: 0
你应该重写 DatePicker
的 PrimaryHueMidBrush
以更改图标的颜色:
<DatePicker materialDesign:HintAssist.Hint="开始日期" Margin="0,25,0,0"
materialDesign:TextFieldAssist.UnderlineBrush="{StaticResource MainThemeColor3}">
<DatePicker.Resources>
<SolidColorBrush x:Key="PrimaryHueMidBrush" Color="红色" />
</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>
英文:
You should override the PrimaryHueMidBrush
for the DatePicker
to change the colour of the icon:
<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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论