The problem in this particular case is that the converter needs to access the window's DataContext,so I decided to implement it in the window's code behind
One option would be to make the IValueConverter
it's own class, and create an instance in XAML as you normally would. If you make the converter a DependencyObject
, you could add a dependency property for a UIElement
, and bind the Window (myWindow
) to the property. This would allow the converter to have access to the Window (via it's property) in order to fetch the DataContext.
The converter could just be referenced as normal within the binding in this design.