I have an IValueConverter whose job it is to convert a BlockId to a ConditionLabel. The problem is that my Model object is what has the smarts to do the actual conversion. My code looks like this so far...
public class BlockIdToConditionLabelConverter : IValueConverter
{
private Model _model;
public BlockIdToConditionLabelConverter(Model model)
{
_model = model;
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int blockId = (int)value;
return _model.BlockIdToConditionLabel(blockId);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
}
At the moment, I create a static resource in a ResourceDictionary like this (and later refer to it in a DataTemplate):
<local:BlockIdToConditionLabelConverter
x:Key="_blockIdToConditionLabelConverter" />
The problem is, I need a way to pass my Model object into this converter. How would I do that?
Thanks.