Skip to Content
Introducing .NET 4.0: with Visual Studio 2010
book

Introducing .NET 4.0: with Visual Studio 2010

by Alex Mackey
February 2010
Beginner content levelBeginner
400 pages
11h 13m
English
Apress
Content preview from Introducing .NET 4.0: with Visual Studio 2010

14.15. Loading XAML Dynamically

Silverlight allows you to load XAML at runtime. You might want to do this to reduce your application size, spread out loading through your application's lifetime, or dynamically load content. When you have retrieved your XAML content as a string, you need to pass it into the XamlReader.Load() method. All that is then necessary to do is cast the results of XamlReader.Load() to the type of object the XAML represents.

When constructing the XAML, be sure to add the xmlns namespace property to your objects; otherwise, Silverlight will be unable to determine the type of object you are trying to create. The following is a simple example illustrating loading a TextBlock from a string that would be placed in the code behind ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 For Dummies®

ASP.NET 3.5 For Dummies®

Ken Cox
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9781430224556Purchase book