我想在SharpDevelop 4.2中使用IronPython创建一个WPF应用程序。但是我对如何在Window1.xaml中访问我的对象感到困惑。
请帮帮我..:)
下面是由SharpDevelop 4.2自动创建的代码:
Window1.xaml
<?xml version="1.0" encoding="utf-8"?>
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="wpf01"
Height="300"
Width="300">
<StackPanel
Margin="15"
x:Name="stackPanel">
<Button
FontSize="24"
x:Name="button">
<Button.BitmapEffect>
<DropShadowBitmapEffect />
</Button.BitmapEffect>
Push Me
</Button>
<TextBox
x:Name="txtName"
Width="120"
Height="20"
Text="aaaaa" />
</StackPanel>
</Window>Window1.py
import wpf
from System.Windows import Window
class Window1 (Window):
def __init__(self):
wpf.LoadComponent(self, 'Window1.xaml')Application.py
import wpf
from System.Windows import Application
from Window1 import Window1
window = Window1()
app = Application()
app.Run(window)发布于 2012-08-24 20:32:42
通过访问您的对象,我假设您希望从代码访问在xaml中定义的文本框和按钮。
您可以通过在Window1类上定义属性或字段来完成此操作。以GUI development with IronPython and Visual Studio 2010为例。
https://stackoverflow.com/questions/12100875
复制相似问题