<div>I write a blog about this topic, link:<a href="http://www.cnblogs.com/redmoon/archive/2008/03/08/1096331.html">http://www.cnblogs.com/redmoon/archive/2008/03/08/1096331.html</a></div>
<div>It is be writed in Chinese.<br><br></div>
<div class="gmail_quote">On Tue, Mar 11, 2008 at 8:15 AM, Jimmy Schementi <<a href="mailto:Jimmy.Schementi@microsoft.com">Jimmy.Schementi@microsoft.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Yep, that's the way to do it =)<br><br>Ideally, this would be abstracted away in a silverlight.py utility module ... which I see as largely community driven ... so feel free to share anything you think would be great to reuse across all python Silverlight apps.<br>
<font color="#888888"><br>~js<br></font>
<div class="Ih2E3d"><br>> -----Original Message-----<br>> From: <a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-">users-</a><br></div>
<div>
<div></div>
<div class="Wj3C7c">> <a href="mailto:bounces@lists.ironpython.com">bounces@lists.ironpython.com</a>] On Behalf Of Dino Viehland<br>> Sent: Monday, March 10, 2008 5:12 PM<br>> To: Discussion of IronPython<br>> Subject: Re: [IronPython] how to use IronPython in Silverlight 2<br>
><br>> That's just Application.Current.RootVisual = myCanvas<br>><br>> This is what I've been doing in my own Silverlight experiments, but I<br>> suck at using XAML and Blend :)<br>><br>> -----Original Message-----<br>
> From: <a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-">users-</a><br>> <a href="mailto:bounces@lists.ironpython.com">bounces@lists.ironpython.com</a>] On Behalf Of Michael Foord<br>
> Sent: Monday, March 10, 2008 4:32 PM<br>> To: Discussion of IronPython<br>> Subject: Re: [IronPython] how to use IronPython in Silverlight 2<br>><br>> Jimmy Schementi wrote:<br>> ><br>> > To load a XAML file and set the RootVisual, you can do this:<br>
> ><br>> > Application.Current.LoadRootVisual("file.xaml")<br>> ><br>> > It's how we do it in the python samples on<br>> <a href="http://dynamicsilverlight.net/" target="_blank">http://dynamicsilverlight.net</a><br>
> ><br>><br>> Suppose you don't want to load a XAML file - how do you do that (but<br>> say<br>> set a 'Canvas' instance you have created programatically) ?<br>><br>> Michael<br>><br>
><br>> > ~Jimmy<br>> ><br>> > *From:* <a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a><br>> > [mailto:<a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a>] *On Behalf Of *Dino<br>
> Viehland<br>> > *Sent:* Friday, March 07, 2008 11:25 AM<br>> > *To:* Discussion of IronPython<br>> > *Subject:* Re: [IronPython] how to use IronPython in Silverlight 2<br>> ><br>> > One problem is that XamlReader.Load takes the string of XAML and not<br>
> a<br>> > filename. But there's something about the XAML that isn't working<br>> > right too. I'm no XAML expert but simplifying it to the code below<br>> > works, you can probably build something up from that. Personally for<br>
> > my Silverlight hacking I've just been building up the tree<br>> > programmatically from Python code even though that's uncool J.<br>> ><br>> > from System.Windows import Application<br>
> ><br>> > from System.Windows.Markup import XamlReader<br>> ><br>> > Application.Current.RootVisual = XamlReader.Load("""<br>> ><br>> > <Canvas Width="100" Height="100"<br>
> > xmlns="<a href="http://schemas.microsoft.com/client/2007" target="_blank">http://schemas.microsoft.com/client/2007</a>"<br>> > xmlns:x="<a href="http://schemas.microsoft.com/winfx/2006/xaml" target="_blank">http://schemas.microsoft.com/winfx/2006/xaml</a>"><br>
> ><br>> > <TextBlock FontSize="30" Text="hello world"/><br>> ><br>> > </Canvas>""")<br>> ><br>> > *From:* <a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a><br>
> > [mailto:<a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a>] *On Behalf Of *Kevin Chu<br>> > *Sent:* Friday, March 07, 2008 9:32 AM<br>> > *To:* Discussion of IronPython<br>
> > *Subject:* Re: [IronPython] how to use IronPython in Silverlight 2<br>> ><br>> > hi Dino<br>> ><br>> > Thanks for your reply.<br>> ><br>> > But I try my sample (look attachment), It can't run! Is my code<br>
> mistake ?<br>> ><br>> > *IronPython code:*<br>> ><br>> > from System.Windows import Application<br>> > from System.Windows.Markup import XamlReader<br>> ><br>> > class App:<br>
> > def __init__(self):<br>> > Application.Current.RootVisual = XamlReader.Load("app.xaml")<br>> > self.scene = Application.Current.RootVisual.grid<br>> > def start(self):<br>> > # TO DO: Replace this with your application start logic.<br>
> > self.scene.message.Content = "Welcome to Silverlight and IronPython!"<br>> ><br>> > App().start()<br>> ><br>> > *XAML code:*<br>> ><br>> > <UserControl x:Class="System.Windows.Controls.UserControl"<br>
> > xmlns="<a href="http://schemas.microsoft.com/client/2007" target="_blank">http://schemas.microsoft.com/client/2007</a>"<br>> > xmlns:x="<a href="http://schemas.microsoft.com/winfx/2006/xaml" target="_blank">http://schemas.microsoft.com/winfx/2006/xaml</a>"><br>
> ><br>> > <Grid x:Name="grid" Background="White"><br>> > <TextBlock x:Name="message" FontSize="30" /><br>> > </Grid><br>> ><br>> > </UserControl><br>
> ><br>> > On Fri, Mar 7, 2008 at 11:55 AM, Dino Viehland<br>> > <<a href="mailto:dinov@exchange.microsoft.com">dinov@exchange.microsoft.com</a> <mailto:<a href="mailto:dinov@exchange.microsoft.com">dinov@exchange.microsoft.com</a>>><br>
> > wrote:<br>> ><br>> > You'll need to download the Silverlight 2 SDK. After installing that<br>> > you'll get all the necessary components installed into something like<br>> > C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client.<br>
> > Also installed is an extremely useful tool called Chiron which you'll<br>> > find somewhere around C:\Program Files\Microsoft<br>> > SDKs\Silverlight\v2.0\Tools\Chiron. Chiron can take your .py file and<br>
> > produce a .xap which includes the IronPython & DLR DLLs using the<br>> > /zipdlr command line option. You can also use it to serve http<br>> > requests and automatically serve up the .xap and let you just edit<br>
> the<br>> > files.<br>> ><br>> > So once you're ready to make your xap the directory you point at<br>> > should contain a .py file (I'm not sure what the multi .py file<br>> > experience is like, but w/ a single file the it doesn't seem the name<br>
> > matters). The simplest thing to put in there is:<br>> ><br>> > from System.Windows import Application<br>> ><br>> > from System.Windows.Markup import XamlReader<br>> ><br>> > Application.Current.RootVisual = XamlReader.Load("someXaml")<br>
> ><br>> > You can see this from the Ruby perspective over at<br>> > <a href="http://www.iunknown.com/2008/03/dynamic-silverl.html" target="_blank">http://www.iunknown.com/2008/03/dynamic-silverl.html</a><br>
> ><br>> > There's various options on how to deploy the DLLs, and you can get<br>> > into manifest files to deploy additional DLLs, but hopefully that'll<br>> > get you started.<br>> ><br>
> > *From:* <a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a><br>> > <mailto:<a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a>><br>
> > [mailto:<a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a><br>> > <mailto:<a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a>>] *On Behalf Of *Kevin Chu<br>
> > *Sent:* Thursday, March 06, 2008 7:39 PM<br>> > *To:* Discussion of IronPython<br>> > *Subject:* [IronPython] how to use IronPython in Silverlight 2<br>> ><br>> > Silverlight 2 beta1 tools for VS2008 only create C# code file,<br>
> ><br>> > How to create a IronPython code file?<br>> ><br>> > --<br>> > Once in a Redmoon<br>> ><br>> ><br>> > _______________________________________________<br>> > Users mailing list<br>
> > <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a> <mailto:<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a>><br>> > <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
> ><br>> ><br>> ><br>> ><br>> > --<br>> > Once in a Redmoon<br>> ><br>> > ---------------------------------------------------------------------<br>> ---<br>> ><br>> > _______________________________________________<br>
> > Users mailing list<br>> > <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>> > <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
> ><br>><br>> _______________________________________________<br>> Users mailing list<br>> <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>> <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
> _______________________________________________<br>> Users mailing list<br>> <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>> <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Once in a Redmoon