In versions earlier than SilverlightCodeYou can set breakpoints to track debugging. In Silverlight 5 beta, you can set breakpoints for The XAML code of the binding data to track the corresponding data binding process.
First, create a Silverlight 5 application.ProgramAnd then prepare the background data code as follows to bind a DataGrid Control.
Public Mainpage ()
{
Initializecomponent ();
List < Cityinformation > Citylist = New List < Cityinformation > (){
New Cityinformation () {cityname = " Beijing " , Addrname = " Beijing, China " , Telnum = " 010 " },
New Cityinformation () {cityname = " Chengdu " , Addrname = " Sichuan, China " , Telnum = " 028 " },
New Cityinformation () {cityname = " Tokyo " , Addrname = " Tokyo, Japan " , Telnum = " 110 " },
New Cityinformation () {cityname = " Guangzhou " , Addrname = " Guangdong, China " , Telnum = " 020 " },
New Cityinformation () {cityname = " Paris " , Addrname = " Paris, France " , Telnum = " 01x " }
};
This . Showcitylist. itemssource = Citylist;
}
}
/// <Summary>
/// Entity of city information
/// </Summary>
Public Class Cityinformation
{
Private String _ Addrname;
Private String _ Cityname;
Private String _ Telnum;
Public String Addrname
{
Get { Return _ Addrname ;}
Set {_ Addrname = Value ;}
}
Public String Cityname
{
Get { Return _ Cityname ;}
Set {_ Cityname = Value ;}
}
Public String Telnum
{
Get { Return _ Telnum ;}
Set {_ Telnum = Value ;}
}
}
1. Set the XAML breakpoint first, as shown in:
2. The running program stops at the position of the XAML code that sets the breakpoint, and we can see the current "bindingstate" in the "local variables" window below, such:
3. In "finalsource", the fields related to the data binding source class are as follows:
4. In "binding" --> "[system. Window. Data. Binding]" --> "path", the addrname is the field name bound to the column, as shown in:
5. The value under "[system. Windows. Data. debugging. updatetargetpipeline]" --> "initialvalue" is the value of addrname, as shown in:
6. Press the F11 key to start debugging the breakpoint in The XAML. The "no source available" page is displayed, as shown in:
7. Don't be flustered. Click "show decompilation" to continue tracking and debugging the XAML binding. continue to pay attention to the "local variables" window. The following interface is displayed:
8. Press the F11 key to track and debug the "telnum" Field of the current row. The current trace value is "010 ".
9. Press the F11 key to switch to the next data row. The following interface is displayed, showing the class information of the next data row:
10. Press the F11 key until all the information has been debugged. the following result is displayed:
This instance uses vs2010 + Silverlight 5.0 Beta. To download the source code, click sl5binding.zip.