XAML trigger as StaticResource

Posted by adrianm on Stack Overflow See other posts from Stack Overflow or by adrianm
Published on 2010-04-30T09:30:14Z Indexed on 2010/04/30 9:37 UTC
Read the original article Hit count: 566

Filed under:
|
|

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"

© Stack Overflow or respective owner

Related posts about wpf

Related posts about xaml