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 ...

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.