次の方法で共有


Silverlight Show: 10 Laps around Silverlight 5 (Part 8 of 10)

In this article, a discussion about productivity and performance enhancements in Silverlight 5 including: XAML Binding Debugging, Parser Performance Improvements and Multi-core JIT for improved start-up time. Please review the Roadmap for the series before going any further.

The Roadmap for this Series

Included, the Roadmap for the series below as you may want to visit other sections as you learn Silverlight 5. I picked the following features as I thought that you may find them useful in your day-to-day work. If you want a specific topic covered then please leave it in the comments below.

  1. Introduction to SL5 – provides a brief history of Silverlight and relevant links.
  2. Binding - Ancestor Relative Source Binding and Implicit Data Templates.
  3. Graphics - XNA 3D API and Improved Graphics Stack.
  4. Media - Low-Latency Sound using XNA and Remote Control and Media Command (Keys) Support.
  5. Text - Text Tracking and Leading, Linked and Multi-column Text, OpenType Support, Pixel Snapped Text and TextOptions.
  6. Operating System Integration Part 1 - P/Invoke, Multiple Windows and Unrestricted File System Access in Full Trust.
  7. Operating System Integration Part 2 - Default Filename for SaveFileDialog, 64-bit browser support and Power Awareness.
  8. Productivity and Performance - [This Post] - XAML Binding Debugging, Parser Performance Improvements and Multi-core JIT for improved start-up time.
  9. Controls - Double and Triple click support, PivotViewer and ComboBox Type-Ahead.
  10. Other items - In-Browser HTML, PostScript and Tasks for TPL

XAML Binding Debugging

XAML Binding Debugging, is one of the most important features in the Silverlight 5. We have all been stuck with Binding expressions at one point or another and wanted an easier way to debug them. Now anywhere that you see a {Binding} expression you can put a break point on it just like your typical C# code. Let’s take a look at a sample:

Fire up a new Silverlight 5 project and give it any name that you want.

Go ahead and add a new class to the project named Podcast.cs and add the following code.

    1: public class Podcast
    2:    {
    3:        public string Description { get; set; }
    4:        public DateTime ReleaseDate { get; set; }
    5:        public Uri Link { get; set; }
    6:  
    7:        public Podcast(string description, DateTime releasedate, Uri link)
    8:        {
    9:            Description = description;
   10:            ReleaseDate = releasedate;
   11:            Link = link;
   12:        }
   13:    }

Let’s switch back over to the MainPage.xaml.cs and add the following code:

    1: public MainPage()
    2: {
    3:     InitializeComponent();
    4:     Loaded += new RoutedEventHandler(MainPage_Loaded);
    5: }
    6:  
    7: void MainPage_Loaded(object sender, RoutedEventArgs e)
    8: {
    9:     this.DataContext =
   10:         new Podcast("This Developer's Life - Criticism",
   11:             new DateTime(2011, 4, 21),
   12:             new Uri("https://thisdeveloperslife.com/post/2-0-1-criticism", UriKind.Absolute)
   13:             );
   14:  
   15: }

Switch back over to the MainPage.xaml and add in the following code replacing the current Grid:

    1: <Grid x:Name="LayoutRoot" Background="White">
    2:        <StackPanel Orientation="Vertical">
    3:            <TextBlock Text="{Binding Description}" />
    4:            <TextBlock Name="txtReleaseDate" Text="{Binding ReleaseDate}" />
    5:            <HyperlinkButton Content="Listen to this Episode" NavigateUri="{Binding Lik}" TargetName="_blank" />
    6:        </StackPanel>
    7: </Grid>

While here, go ahead and put a break point on the “Hyperlink" button line, which you can do by clicking outside its margin as shown below:

1

Notice the Red Circle and the highlighted “Binding” word? The Visual Studio 2010 debugger will stop once the XAML parser hits that line.

 

Read the full post

Comments

  • Anonymous
    December 02, 2011
    come on ! forget the show ! just release the bits !!

  • Anonymous
    December 07, 2011
    It's very good! Exusme for my wors English

  • Anonymous
    December 08, 2011
    The comment has been removed