如何在WPF中为窗体上的窗口属性值赋值控制?

时间:2016-09-16 23:10:43

标签: wpf data-binding

假设有MainWindow形式,它具有属性字符串属性Propery1。如何将此属性值分配给txtDisplay.Text属性?控件txtDisplay放在MainWindow表单上。

public partial class MainWindow : Window
    {
      ...
        public bool Propery1
        {
            get { return this.txtDisplay.Text.Length > 0; }
        }
 ...
}

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Binary Calculator" Height="350" Width="625">
    ...
        <TextBox  Name="txtDisplay"  Style="{StaticResource MyTextBox}"  MaxLength="32" Grid.Column="0" Grid.Row="0"  Grid.ColumnSpan="6" KeyDown="txtDisplay_KeyDown"/>
...
</Window>

0 个答案:

没有答案