tags:

views:

74

answers:

0

Why can't I create a trigger and use it as a static resource in XAML?

<Window.Resources>
    <Trigger x:Key="ValidationTrigger" x:Shared="False" Property="Validation.HasError" Value="true">
        <Setter Property="FrameworkElement.ToolTip"
                Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                Path=(Validation.Errors)/ErrorContent}"/>
    </Trigger>

    <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
        <Style.Triggers>
            <StaticResource ResourceKey="ValidationTrigger"/>
        </Style.Triggers>
    </Style>
</Window.Resources>

I get an errormessage at runtime
"Value cannot be null.
Parameter name: triggerBase Error at object 'System.Windows.Markup.StaticResourceHolder' in markup file"