Question

I want to create a WPF application using IronPython with SharpDevelop 4.2. But I am confused how to access my object in the Window1.xaml.

Please help.. :)

Here is my code created automatically by 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)
Was it helpful?

Solution

By access your object I am assuming you want to access the text box and button you have defined in your xaml from code.

You can do this by defining properties or fields on the Window1 class. Take a look at GUI development with IronPython and Visual Studio 2010 for an example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top