Hi,
I set up a simple multibinding like this:
<Border removed="#FF880000" BorderThickness="1" BorderBrush="Black" CornerRadius="5" Margin="5">
<TextBox removed="Transparent" MaxLength="3" Text="{Binding ElementName=SRed, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Foreground="WhiteSmoke" MinWidth="40" Margin="2" BorderBrush="Transparent"/>
</Border>
<Border removed="#FF008800" BorderThickness="1" BorderBrush="Black" CornerRadius="5" Margin="5">
<TextBox removed="Transparent" MaxLength="3" Text="{Binding ElementName=SGreen, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Foreground="WhiteSmoke" MinWidth="40" Margin="2" BorderBrush="Transparent"/>
</Border>
<Border removed="#FF000088" BorderThickness="1" BorderBrush="Black" CornerRadius="5" Margin="5">
<TextBox removed="Transparent" MaxLength="3" Text="{Binding ElementName=SBlue, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Foreground="WhiteSmoke" MinWidth="40" Margin="2" BorderBrush="Transparent"/>
</Border>
<Border removed="#FF666666" BorderThickness="1" BorderBrush="Black" CornerRadius="5" Margin="5">
<TextBox removed="Transparent" MaxLength="3" Text="{Binding ElementName=SA, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Foreground="WhiteSmoke" MinWidth="40" Margin="2" BorderBrush="Transparent"/>
</Border>
<Border removed="#FF00B9B9" BorderThickness="1" BorderBrush="Black" CornerRadius="5" Margin="5">
<TextBox removed="Transparent" Foreground="WhiteSmoke" MinWidth="40" Margin="2" BorderBrush="Transparent">
<TextBox.Text>
<MultiBinding Converter="{StaticResource RTHC}" Mode="TwoWay">
<Binding ElementName="SRed" Path="Value" />
<Binding ElementName="SGreen" Path="Value" />
<Binding ElementName="SBlue" Path="Value" />
<Binding ElementName="SA" Path="Value" />
</MultiBinding>
</TextBox.Text>
</TextBox>
</Border>
Which is a twoWay MultiBinding to the other textboxes.
Then I created this class:
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
byte R = byte.Parse(values[0].ToString());
byte G = byte.Parse(values[1].ToString());
byte B = byte.Parse(values[2].ToString());
byte A = byte.Parse(values[3].ToString());
return DecToHex(A) + DecToHex(R) + DecToHex(G) + DecToHex(B);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
string v = value.ToString();
return new object[4] { HexToDec(v.Substring(0, 2)), HexToDec(v.Substring(2, 2)), HexToDec(v.Substring(4, 2)), HexToDec(v.Substring(6, 2)) };
}
Eberything is implemented correctly, but the textboxes do not get updated when I change the value in the textbox I set the multibinding in.
Here are some screenshots:
http://snap.ashampoo.com/Yvu9z61n[
^]
http://snap.ashampoo.com/Z6Rmvl6u[
^]
http://snap.ashampoo.com/fVwFrBI8[
^]
Thanks.
---Jymmy097