New Features of Silverlight 5 beta Exploration Series: 2. Set breakpoint and binding debugging in The XAML code [with source code instance]

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.