public class MyUser {
public string UserName { get; set; }
}
public string UserName { get; set; }
}
文字方塊繫結如下
<TextBox>
<TextBox.Text>
<Binding Path="Name" />
</TextBox.Text>
</TextBox>
MainWindow Contructor如下
public MainWindow() {
InitializeComponent();
this.DataContext = new MyUser() { UserName = "Mary" };
}
InitializeComponent();
this.DataContext = new MyUser() { UserName = "Mary" };
}
執行後檢視Output Window只看到Error 40的訊息
重寫一下設定,Textbox設定TraceLevel為High
<Window x:Class="P5_21_TraceLevel.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
>
<Grid x:Name="roor">
<TextBox>
<TextBox.Text>
<Binding Path="Name"
diag:PresentationTraceSources.TraceLevel="High"/>
</TextBox.Text>
</TextBox>
</Grid>
</Window>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
>
<Grid x:Name="roor">
<TextBox>
<TextBox.Text>
<Binding Path="Name"
diag:PresentationTraceSources.TraceLevel="High"/>
</TextBox.Text>
</TextBox>
</Grid>
</Window>
適當設定Visual Studio 2010 Debugging
重Run,Output window會多顯示更多的資訊出來
沒有留言:
張貼留言