February 2013
Beginner to intermediate
68 pages
1h 50m
English
If you’re used to writing code in Visual Basic, you know that with XML Literals you can embed any kind of XML markup in your code; this rule includes XAML markup. For instance, you can declare a button as follows:
Dim testControl = <Button Width="100" Height="50" Name="Button1">Test</Button>
To make this line usable in the application, you need to import the XAML default namespaces:
Imports <xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/ presentation">Imports <xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml">
You can then easily parse the control definition by invoking the XamlReader.Parse method as follows:
Dim myButton = CType(System.Windows.Markup. XamlReader.Parse(testControl.ToString), ...