开发者

Please help move WPF trigger behavior to Silverlight

开发者 https://www.devze.com 2023-04-06 12:20 出处:网络
The WPF code: <TextBox> <TextBox.Resources> <Style TargetType=\"TextBox\"> <Style.Triggers>

The WPF code:

 <TextBox>
        <TextBox.Resources>
            <Style TargetType="TextBox">
                <Style.Triggers>
                    <Trigger Property="Text" Value="1">
                        <Setter Property="Background" Value="Red"/>
                    </Trigger>
                    <Trigger Property="Text" Value="2">
                        &开发者_运维技巧lt;Setter Property="Background" Value="Green"/>
                    </Trigger>
                    <Trigger Property="Text" Value="3">
                        <Setter Property="Background" Value="Blue"/>
                    </Trigger>

                </Style.Triggers>
            </Style>
        </TextBox.Resources>
    </TextBox>

Can you write the same in Silverlight? Please dont vote to close this question. Thanks!


Or... you can install the "Blend SDK" (it's free), which extends Silverlight's triggers and allows you to do exactly that.


Triggers are not supported in Silverlight. You can use a IValueConverter to change the value to the correct color.

0

精彩评论

暂无评论...
验证码 换一张
取 消