# Reference the WPF assemblies
import
clrclr
.AddReference("PresentationFramework.Classic, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")clr
.AddReference("PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")import
System.WindowsApplication
= System.Windows.Applicationfrom
System.Windows.Markup import XamlReaderclass
XamlLoader(object): def __init__(self, xmlData):self
.Root = XamlReader.Parse( xmlData ) def __getattr__(self, item): return self.Root.FindName(item)xamldata
= """<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WpfApplication3" Height="300" Width="300">
<Grid></Grid>
</Window>
"""
xaml
= XamlLoader( xamldata )my_app
= Application()my_app
.Run(xaml.Root)