2012-08-23 2 views
1

IronPython과 SharpDevelop 4.2를 사용하여 WPF 응용 프로그램을 만들고 싶습니다. 그러나 Window1.xaml에서 내 개체에 액세스하는 방법을 혼동합니다.SharpDevelop + IronPython + WPF

.. 도와주세요 :)

여기 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') 

응용 프로그램. 파이

import wpf 

from System.Windows import Application 
from Window1 import Window1 

window = Window1() 
app = Application() 
app.Run(window) 

답변

1

개체에 액세스하면 코드에서 xaml에 정의한 텍스트 상자와 단추에 액세스하려고한다고 가정합니다.

Window1 클래스에서 속성이나 필드를 정의하여이 작업을 수행 할 수 있습니다. 예를 들어 GUI development with IronPython and Visual Studio 2010을 살펴보십시오.