O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

XamlReader

XamlReader exposes a simple Load method that accepts a string and returns a System.Object. It parses the XAML in the string, creates the appropriate objects, and returns an instance of the root element.

If you have a string containing XAML content whose root element is a Page object, the following C# code could be used to load and retrieve the root Page instance:

string xamlString = ...;// Get the root element, which we know is a PagePage p = (Page)XamlReader .Load(xamlString);

After Load returns, the entire hierarchy of objects in the XAML file is instantiated in memory, so the XAML itself is no longer needed. Now that an instance of the root element exists, you can retrieve child elements by making use ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required