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"
I imagine that this is because resources are loaded first.
So in this case, WPF would try to load your trigger before any control it might be associated with. Then the trigger value can't be evaluated at that time.
But that need to be confirmed :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With