如何将Text
的属性绑定TextBox
到FoundationHeight
代码隐藏中定义的 clr-property。
xaml
<TextBox Text="{Binding FoundationHeight}"/>
Run Code Online (Sandbox Code Playgroud)
C#
public double FoundationHeight { get; set; }
public AssignColumnPropertiesWindow()
{
InitializeComponent();
FoundationHeight = 60;
}
Run Code Online (Sandbox Code Playgroud)
使用RelativeSource
。
如果为您的 UserControl 定义了代码隐藏:
<TextBox Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=FoundationHeight}" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2992 次 |
最近记录: |