Tag: multibinding

多表格绑定数据

我的项目有两个WPF表单:Form1和Form2。 在Form1中,我有1个按钮来调用Form2,textBox1,textBox2,textBox3,textBox4,Form2只有一个textBox和一个Save按钮。 所以当我点击按钮时,它会显示Form2。 在textBox中我创建了一个模板文本,如: “blablabla %txt1% blablabla %txt2% blabla %txt3% blabla” 我单击“保存”按钮以保存它。 返回Form1时,textBox4将显示模板文本中的内容,其中%txt1%,%txt2%,%txt3%将更改取决于textBox1,textBox2,textBox3。 我打算使用MultiBinding将textBox1,2,3中的内容绑定到textBox4中,就像这样: <MultiBinding StringFormat = "blablabla {0} blablabla {1} blabla {2} blabla" 而我的问题是:如何获得 “blablabla {0} blablabla {1} blabla {2} blabla” 从Form2中的textBox并将其放到StringFormat?

WPF MultiBindings

我需要在不使用XAML的情况下直接在C#中实现MultiBindings,我知道如何在C#中使用IMultiValueConverter,但是,如何做: 在C#?

转换器中的WPF MultiBinding失败==> DependencyProperty.UnsetValue

我的代码在启动时失败,因为Multibinding调用的Converter中的values数组没有填充适当的值但是具有 DependencyProperty.UnsetValue 的值 。 看看转换器,看看我在哪里得到错误 public class ButtonColorConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { string val1 = string.Format(” {0} “, values[0]); string val2 = (string)values[1]; **//Here i am getting ==> {DependencyProperty.UnsetValue}** return val1.Equals(val2) ? Brushes.NavajoWhite : Brushes.White; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo […]

WPF CommandParameter MultiBinding值为null

我只是尝试将两个控件绑定为命令参数,并将它们作为object[]传递给我的命令。 XAML: GENERAL INFORMATION Test 命令: public ICommand ExpanderCommand { get { return new RelayCommand(delegate(object param) { var args = (object[])param; var content = (UIElement)args[0]; var button = (Button)args[1]; content.Visibility = (content.Visibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible; button.Content = (content.Visibility == Visibility.Visible) ? “-” : “+”; }); } } 转换器: public class MultiValueConverter : […]

如何将三个滑块的值转换为颜色?

我正在尝试创建一个自定义用户控件,允许用户在WPF中定义颜色。 我之前在WinForms中做过这个,但在WPF中它似乎并不那么直接。 这也是我第一次处理多转换器。 控件有3个滑块 – 就像这样: 唯一的区别是每个的名称 – sdrRed,sdrGreen和sdrBlue。 这是多值转换器: public class ByteToColorConverter : IMultiValueConverter { public object Convert( object[ ] values, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { return Color.FromArgb( (byte)values[0], (byte)values[1], (byte)values[2], (byte)values[3]); } public object[ ] ConvertBack( object value, Type[ ] targetTypes, object parameter, System.Globalization.CultureInfo culture ) { Color C = […]