7
<TextBlock Text="{Binding MyTextProperty}">
    <TextBlock.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 ?

Theun Arbeider
  • 5,259
  • 11
  • 45
  • 68

1 Answers1

11

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

Community
  • 1
  • 1
ColinE
  • 68,894
  • 15
  • 164
  • 232
  • I'm having the same problem with x:Type ToggleButton, and I've tried your solution : TargetType="{ToggleButton}" but not I'm getting the error: Type 'ToggleButton' is used like a markup extension but does not derive from MarkupExtension. What does that mean ? – NadaNK Dec 21 '12 at 07:40
  • 2
    @Nada There should be TargetType="ToggleButton" without curly brackets – lisp Jun 28 '13 at 08:04