I have a converter thats works great when I use it as StaticResource on my Window as follows
<UserControl.Resources>
<local:Vali开发者_运维知识库dationErrorConverter x:Key="validationErrorConverter"/>
</UserControl.Resources>
I have a ResourceDictionary that defines my controls ControlTemplates and Styles , I couldn't figure out where to reference my converter as a StaticResource to be able to use it on 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>
Just create a new one, if the converter is needed for a Style just use Style.Resources
for it. Or you could use element syntax:
<Setter.Value>
<Binding Path="(Validation.Errors).CurrentItem"
RelativeSource="{RelativeSource Self}">
<Binding.Converter>
<local:ValidationErrorConverter />
</Binding.Converter>
</Binding>
</Setter.Value>
精彩评论