工具包时如何更改背景:TimePicker被禁用?

时间:2014-01-03 16:24:35

标签: c# wpf

我在toolkit:TimePicker中使用WPF作为下面的代码

<toolkit:TimePicker x:Name="datetimeBeginBackup"
                    Format="Custom"
                    FormatString="HH:mm:ss"
                    TextAlignment="Center"
                    Foreground="#FFFFFF">
    <toolkit:TimePicker.Background>
        <ImageBrush ImageSource="Resources\backup_date_time_picker_bgr.png"/>
    </toolkit:TimePicker.Background>
</toolkit:TimePicker>

禁用datetimeBeginBackup时,会出现白色背景,但不好。

我想通过图片datetimeBeginBackup更改"backup_date_time_picker_disable_bgr.png"的背景,但我不知道该怎么做。

有人可以帮助我吗?

非常感谢,

T&amp; T公司

1 个答案:

答案 0 :(得分:1)

您可以通过样式执行此操作:

<toolkit:TimePicker x:Name="datetimeBeginBackup"
            Format="Custom"
            FormatString="HH:mm:ss"
            TextAlignment="Center"
            Foreground="#FFFFFF">
    <toolkit:TimePicker.Style>
        <Style TargetType="toolkit:TimePicker">
            <Setter Property="Background">
                <ImageBrush ImageSource="Resources\backup_date_time_picker_bgr.png"/>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Background">
                        <ImageBrush ImageSource="Resources\backup_date_time_picker_disable_bgr.png"/>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </toolkit:TimePicker.Style>
</toolkit:TimePicker>