[IronPython] Referring to Python types in Xaml
Bish Bosh
unittesting at gmail.com
Thu May 17 17:45:59 CEST 2007
What is the mechanism for making types in the Python domain available
to the WPF type system for use in a Xaml file?
In the code below I am refering to the Python class to do some
formatting but would have the same problem if I was trying to create
an instance of a Python class in the Xaml file. Any ideas? I'm pretty
sure I'm missing something simple but fundamental. As usual.
In Python file I have a type:
class FancyData(ObservableCollection[str]):
pass
The collection to be displayed I am adding as an application resource:
app.Resources.Add('collection', FancyData())
So it can be bound to as expected in the Xaml:
<ListBox ItemsSource="{Binding Source={StaticResource collection}}"/>
In Xaml file I would like to refer to the type to do some formatting:
<DataTemplate DataType="{x:Type FancyData}">
<StackPanel>
...
I get the error:
File data1.py, line 108, in Initialize
File , line 0, in _stub_##77
File data1.py, line 26, in LoadXaml
File , line 0, in _stub_##87
File PresentationFramework, line unknown, in Load
File PresentationFramework, line unknown, in XmlTreeBuildDefault
File PresentationFramework, line unknown, in Parse
File PresentationFramework, line unknown, in ParseFragment
File PresentationFramework, line unknown, in _Parse
File PresentationFramework, line unknown, in ReadXaml
File PresentationFramework, line unknown, in Read
SystemError: Type reference cannot find public type named 'FancyData'.
More information about the Ironpython-users
mailing list