On Thu, Jul 28, 2011 at 12:42 PM, zdong <zd...@rliansoft.com> wrote:
> dear jimmy
>
> Acturally i want to create instance of StackPanel,TextBlock ect. That been
> widly known as silverlight standard framework element in
> system.windows.controls. If i directly use stackins=StackPanel() it's seems
> could not found StackPanel class . So that's way i want to import
> system.windows.controls namespace.

See 
http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel(v=vs.95).aspx).

While System.Windows.Controls is the namespace where StackPanel and
TextBlock are named in, they are located in the System.Windows
assembly, which is in System.Windows.dll. .NET assemblies are
references with clr.AddReference, which then allows you to import the
namespaces from that assembly as if they where Python modules.

So here's how you'd create a StackPanel in Silverlight using IronPython:

import clr
clr.AddReference("System.Windows")
from System.Windows.Controls import StackPanel, TextBlock

s = StackPanel()
s.Children.Add(TextBlock(Text="Block1"))
s.Children.Add(TextBlock(Text="Block2"))
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to