wpf datepicker

孤人 提交于 2020-01-16 05:23:27

问题


Ok i'm trying to style the datepicker from microsoft from their wpftoolkit.dll. I have it in a grid that is disabled, unfortunately it's background color stays white(despite it being disabled) unlike the other controls that gray out.

Ok I did do this:

    <Style TargetType="{x:Type tk:DatePicker}">
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="LightGray"/>
            </Trigger>
        </Style.Triggers>
    </Style>

But the text inside it that displays "Show Calendar" still has a white background. How do I set a style to make it look like the other controls i.e. gray out all of the background?


回答1:


The background of the "Show Calendar" text (the part of the control that shows the currently selected date) is a "DatePickerTextBox" that's sitting inside the date picker. To set its background, use:

<Style TargetType="{x:Type tk:DatePickerTextBox}">
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Background" Value="LightGray"/>
        </Trigger>
    </Style.Triggers>
</Style>


来源:https://stackoverflow.com/questions/956614/wpf-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!