You can use a ResourceDictionary
.
Just add it in the solution explorer with Add -> Resource dictionary
Declare your Converter
there like
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<BooleanToVisibilityConverter x:Key="BooleanToVisibility" />
</ResourceDictionary>
In your XAML
, you can use it like
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="MyResources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
Now you can use your Converter
anywhere where you have your Resource Dictionary
If you only need your Converter
in your UserControl
(as you mentioned in the Comment above), then you can still declare it like:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="MyResources.xaml" />
<ResourceDictionary>
<BooleanToVisibilityConverter x:Key="MyConverter" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
I just used BooleanToVisibilityConverter
for the example, but it is easy to use your own converter there.