Как мне настроить двухполосную многосвязку?..
Привет,
Я создал простую multibinding такой:
<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>
Что это взаимное MultiBinding в других текстовых полях.
Затем я создал этот класс:
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 реализован правильно, но текстовые поля не обновляются, когда я изменяю значение в текстовом поле, в котором я установил многосвязку.
Вот несколько скриншотов:
http://snap.ashampoo.com/Yvu9z61n[^]
http://snap.ashampoo.com/Z6Rmvl6u[^]
http://snap.ashampoo.com/fVwFrBI8[^]
Спасибо.
---Jymmy097
LLLLGGGG
Кто-нибудь?