TTGroup
TTGroup

Reputation: 3703

How to change background when toolkit:TimePicker is disabled?

I'm using toolkit:TimePicker in WPF as code below

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

When the datetimeBeginBackup is disable, the white background will occur, it is not good.

I want to change the background of datetimeBeginBackup by the image "backup_date_time_picker_disable_bgr.png", but I don't know how to do it.

Someone can help me?

Many Thanks,

T&T

Upvotes: 1

Views: 121

Answers (1)

Matt
Matt

Reputation: 2682

You can do this through a style:

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

Upvotes: 2

Related Questions