Uno degli aspetti interessanti del nuovo linguaggio di markup XAML è la possibilità di avere del codice inline.
<Window x:Class="WindowsApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="Window1_Loaded">
<x:Code>
<![CDATA[
void Window1_Loaded(object sender, RoutedEventArgs e)
{
this.Title="Titolo....";
TextBox txt = new TextBox();
txt.Text="hello dotnetsiders!!!";
this.Content=txt;
}
]]>
</x:Code>
</Window>