This is my View:
<TextBox>
<TextBox.Text>
<MultiBinding UpdateSourceTrigger="PropertyChanged">
<MultiBinding.Converter>
<local:ContentBoxTextConverter />
</MultiBinding.Converter>
<Binding Path="Content" />
<Binding Path="IsA" />
<Binding Path="IsB" />
</MultiBinding>
</TextBox.Text>
</TextBox>
Its Converter:
internal class ContentBoxTextConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string content = values[0] as string;
bool isA = values[1] as bool;
bool isB = values[2] as bool;
if (isA) return "A";
if (isB) return "B";
return content;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
if (value == "A") return [value, true, false];
if (value == "B") return [value, false, true];
return [value, false, false];
}
}
When the value of the property Content
is changed to “A”,
Convert() is called, and the UI ContentBox.Text is updated to “A” correctly.
But then ConvertBack() will not be called so the property IsA
will not be updated to true
I wanna call ConvertBack() after Convert() in multibinding converter so that the source properties’ values can all be updated