WPF 将子控件的属性绑定到父控件的属性中

其实就是在后台代码进行数据绑定

            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#,WPF)