So I've gotten in the habit of using WPF/C# value converters because they are awesome. I usually just have a folder set up for value converters and then access them in whatever xaml files I might need them.
I'm currently developing a user control that will have some value converters that I do not want other classes to be able to access. In other words, value converter exists in the code behind file and should be accessible only from that file and the associated xaml. My first thought was to throw it inside the code behind file as a nested class, but I can't find a way to access the nested class from within the xaml file. Am I going in the right direction or is there something else I should be doing?
I could go the cheap way and just throw this control into its own namespace, but that doesn't really solve my problem.
Any help or guidance is appreciated. Thanks!
Below is roughly what I want:
public partial class MyControl: UserControl
{
//misc code for control
private class MyValueConverter : IMultiValueConverter
{
//conversion functions
}
}
is what I have in mind.
Normally, value converters are accessed from WPF like:
`<local:MyValueConverter x:Key="MyValueConverter" />`
This only works if they are in the same namespace. I cannot get this to work if it is a nested class. I've met my goal of making the valueconverter visible only to this user control, but I cannot figure out for the life of me how to access it from within the xaml.
My problem is accessing this converter from in the xaml.