1

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

アプリケーション.py

import wpf

from System.Windows import Application
from Window1 import Window1

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

1 に答える 1

1

オブジェクトにアクセスすることで、コードから xaml で定義したテキスト ボックスとボタンにアクセスしたいと考えています。

これを行うには、Window1 クラスでプロパティまたはフィールドを定義します。例として、IronPython と Visual Studio 2010 を使用した GUI 開発をご覧ください。

于 2012-08-24T12:32:42.073 に答える