I have an IValueConverter class that is used to change the background color of a datagrid cell in case the value in the cell itself is greater than 0 (not important).
Now I want to create several instances of the window that contains this datagrid. Depending on some values defined in the Window instance the IValueConverter shall color the background of a cell of the datagrid or not. So the IValueConverter shall do a different job depending on the instance of the Window class.
The problem now is: I can't pass ConverterParameter in XAML because that parameter would be a fix one for all instances of the window. I thought about passing the relevant information to the IValueConverter class programmatically (that is required) but how can I access the instance of the IValueConverter class? My current solution: I put some static variables into the IValueConverter class so I can access them from the instance of the Window class. But this solution is a bad one because the variables are static and so the ValueConverter behaves the same way in each of the window instances.
Does anyone know how to access the IValueConverter instance programmatically from the Window instance? Thanks!
Since you cannot databind to the ConverterParameter, you can one of two things (also see this SO question):