开发者

Missing Style.Triggers and x:Type. Why?

<TextBlock Text="{Binding MyTextProperty}">
    <TextBlo开发者_Go百科ck.Style>
        <Style TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding MyTextProperty}" Value="{x:Null}">
                    <Setter Property="Text" Value="Hey, the text should not be empty!" />
                    <Setter Property="Foreground" Value="Red" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </TextBlock.Style>
</TextBlock>

Question 1: Why is <Style TargetType="{x:Type TextBox}"> giving the error The type 'x:Type' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

Question 2: Why am I getting the error The attachable property 'Triggers' was not found in type 'Style'.

Am I missing anything ?


It looks like you are trying to use WPF XAML within Silverlight. Silverlight does not support the {x:Type} markup extension. You can instead use TargetType={TextBox}.

Also, Silverlight does not have DataTrigger support!

See:

What is the replacement for DataTrigger in Silverlight

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜