[IronPython] Gestalt, IronPython in Silverlight and embedded xaml
Jimmy Schementi
Jimmy.Schementi at microsoft.com
Wed Mar 31 04:06:58 CEST 2010
> I still need to package my app into a zip file and serve it locally (doesn't work from the filesystem)
Michael, what do you exactly mean by this? You need your app to run out of browser?
> It doesn't seem to me that embedded xaml is working
First of all, docs/spec issue: the current online bits only support application/xml+xaml, and the docs have application/xaml+xml. The release that will be online in a few days supports both. After correcting that you will get a SL control created on the page; here's the exact HTML (with a Text attribute added to the TextBlock to make it obvious that it worked):
<html>
<head>
<script type="text/javascript" src="http://gestalt.ironpython.net/dlr-latest.js"></script>
</head>
<body>
<script type="application/xml+xaml" id="inlineXAML" width="200" height="75">
<Canvas> <TextBlock Canvas.Left="20" FontSize="24" Text="hi" /> </Canvas>
</script>
</body>
<html>
Then, if you add the following Python script-tag after the XAML script tag, it will update the text:
<script type="text/python" class="inlineXAML">
from System.Windows.Application import Current as app
app.RootVisual.Children[0].Text += " from python"
</script>
Note the *class="inlineXAML"* attribute; if you did not include this, the code would run against a different Silverlight control than the one created by your *id="inlineXAML"* tag. In fact, it would run against a SL control that is essentially hidden, so app.RootVisual would be None. In short, giving a XAML script-tag an ID lets you pick the Python script-tags that will run against it by setting their class attribute to the same value.
I'll update the docs accordingly...
~Jimmy
More information about the Ironpython-users
mailing list