WPF 将子控件的属性绑定到父控件的属性中
程序员文章站
2022-06-08 17:14:48
...
其实就是在后台代码进行数据绑定
TextBlock _scaleTextBlock = new TextBlock();
Binding binding = new Binding()
{
Path = new PropertyPath("Scale"),
Source = this,
StringFormat = "{0:P0}",
Mode = BindingMode.TwoWay
};
_scaleTextBlock.SetBinding(TextBlock.TextProperty, binding);
this.Children.Add(_scaleTextBlock);
推荐阅读
-
C# Winform 子窗体访问父级窗体的控件和属性
-
WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系
-
C# Winform 子窗体访问父级窗体的控件和属性
-
WPF中,一个由Line控件的StrokeDashArray属性引发的CPU占用率问题
-
WPF之PasswordBox控件的Password属性绑定
-
WPF 将子控件的属性绑定到父控件的属性中
-
WPF自定义控件的自定义属性绑定后不更新问题
-
C#数据绑定控件中的DataSource属性浅谈
-
WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系
-
C#数据绑定控件中的DataSource属性浅谈