How to use converter inside ResourceDictionary

I have a converter that works great when I use it as a StaticResource in my window, as shown below.

<UserControl.Resources> <local:ValidationErrorConverter x:Key="validationErrorConverter"/> </UserControl.Resources> 

I have a ResourceDictionary that defines my ControlTemplates and Styles controls, I could not figure out where to reference my converter as a StaticResource in order to be able to use it in my styles as follows

 <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors).CurrentItem, Converter={StaticResource HERE??}}"/> </Trigger> </Style.Triggers> 
+7
source share
1 answer

Just create a new one if a converter is needed for the style, just use Style.Resources for it. Or you can use element syntax:

 <Setter.Value> <Binding Path="(Validation.Errors).CurrentItem" RelativeSource="{RelativeSource Self}"> <Binding.Converter> <local:ValidationErrorConverter /> </Binding.Converter> </Binding> </Setter.Value> 
+12
source

All Articles