[Ironpython-users] problem incorporating namespace into Xaml

John Trinder TrinderJohn at dsl.pipex.com
Fri Jul 25 01:45:00 CEST 2014


I'm new to FePy and after doing a fair bit of studying am embarking on 
transcoding a C# project to FePy. I'm encountering a problem 
incorporating a module that defines a subclass of Canvas and then trying 
to utilize this custom canvas in the Xaml code.

My skeleton files/modules and contents are as follows:

_*module1.py

*_import clr
clr.AddReference('PresentationFramework')
import System.Windows.Controls as swc

class CustomCanvas(swc.Canvas):
     def __init__(self):
         pass_*

*__*WpfApplication1.xaml*_

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
*xmlns:local="clr-namespace:module1"*
        Title="WpfApplication1" Height="300" Width="300">
        <Grid>
*<local:CustomCanvas HorizontalAlignment="Left" Height="100" 
Margin="96,90,0,0" VerticalAlignment="Top" Width="100"/>*
        </Grid>
</Window>

_*WpfApplication1.py*_

import wpf

from System.Windows import Application, Window

class MyWindow(Window):
     def __init__(self):
         wpf.LoadComponent(self, 'WpfApplication1.xaml')

Application().Run(MyWindow())


I've marked in bold where I have incorporated my module/namespace. 
Intellisense says that on the *<local:CustomCanvas .../>* line, 
CustomCanvas 'does not exist in the namespace *"clr-namespace:module1"'*
I'm guessing that it's not possible to do (yet) what I want to do - 
which is pretty basic.
Thanks in advance btw for any advice and tips.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20140725/f5691193/attachment.html>


More information about the Ironpython-users mailing list