假设有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>