Sunday, December 14, 2008

IronPython - SIlverLight

Here is the adapted version of ScottGu sample


from System.Windows import Application
from System.Windows.Controls import UserControl

class App:

root = None

def MyButton_Click(self,s,e):
App.root.MyButton.Content = "Pushed"
App.root.Message.Text = "MyButton has been pushed"

def __init__(self):
App.root = Application.Current.LoadRootVisual(UserControl(), "app.xaml")
App.root.Message.Text = "Welcome to Python and Silverlight!"
App.root.MyButton.Content = "Push Me"
App.root.MyButton.Click += self.MyButton_Click

App()





The xaml code

<UserControl x:Class="System.Windows.Controls.UserControl"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Grid x:Name="layout_root" Background="White">
<TextBlock x:Name="Message" FontSize="55" />
<Button x:Name="MyButton" Content="Push Me" Width="100" Height="50" />
<Grid>

</UserControl>

No comments:

Post a Comment