Compartir a través de


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

In this article, you see how to use Ancestor Relative Source Binding and Implicit Data Templates using Silverlight 5. Please review the Roadmap for the series before going any further.

The Roadmap for this Series

I’ve 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 [This Post] - 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 - 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.

Begin with Ancestor RelativeSource Binding

A new addition to the binding engine in Silverlight is called Ancestor RelativeSource Binding. This was previously available in WPF, but is new to Silverlight 5. With Ancestor RelativeSource Binding you can now bind a child object property to a parent object property. It comes with additional properties to determine the type of parent object and how many levels up it is from the child.

Let’s begin today by looking at a sample ported over from WPF which shows how to retrieve the FontFamily and FontSize for a given TextBlock.

Adding onto our existing project.

Hopefully you have completed part 1 of the series. If not then create a new Silverlight 5 project and name it “BeginnerSilverlight5”, and look under Solution Explorer. Double click the file named MainPage.xaml and replace the grid with the following code…

Read the full post

Comments

  • Anonymous
    November 13, 2011
    And what about wcf silverlight bindings in the new version, can't find any information