I have created a custom MultiValue Converter to perform a bit of logic while MultiBinding to a TextBox; however I do not want to use the convertBack since the binding value does not have a compile-time type and the default conversion works perfectly. Is this possible or do I have to somehow replicate the functionailty of one of the internal default converters?
Diagram:
values --> Convert() --> TextBox
values <---------------- TextBox
Thank you.
Edit: Forgot to mention that I am using a MultiValueConverter and MultiBinding which seems to bypass the default converter.
Edit: To expand on the reasoning behind this: I have two objects A & B (of the same type) that I want to edit simultaneously in a TextBox. In the Convert method, I check if they are the same value and either display the value or a default. If the user changes the value in the TextBox, I want the same value to be sent back to both A & B.
Edit: I have solved the issue in a roundabout fashion - please see my response below. If you have a better solution I would still appreciate hearing it. Thanks again for your time and help.
Just return value in convertback
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return YourLogic(value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
Okay I just figured out a solution... Thanks to everyone for posting suggestions.
It turns out that if you create a pass-through ValueConverter (as in just return value for both Convert and ConvertBack), and add it to the sub-Bindings of the MultiBinding, that the default conversions will happen as expected. What must be happening is that the MultiBinding in general bypasses the defaultConverter of the sub-Bindings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With