Well now I am getting started with XAML and WPF I am hoping to start blogging a bit more! So I was trying to reference a nested type with the {x:Type} markup extension and it wasn't working. Say you have a class as follows:
public class MyClass
{
public class MyInnerClass
{
}
}
You want to reference the inner class (e.g. for a DataTemplate). The following XAML does not work
<DataTemplate DataType="{x:Type MyClass.MyInnerClass}">
What you need to do is:
<DataTemplate DataType="{x:Type MyClass+MyInnerClass}">
Thanks to Seb for the hint on that one!
4 comments:
Cheers. MSDN seems to recommend against it but it works for me. :)
They do? Where is that recommendation?
This works, but it seems that the designer in VS 2008 doesn't like it. I used it in DataTemplate and now I can't see the designer anymore!
Erm that's a bit rubbish really! However I don't use the designer so haven't really had that problem. A lot of things seem to break the designer as far as I can tell!
Give it a go in vs2010, I'd be interested to see how it is there and the designer is supposed to be better
Cheers
Neil
Post a Comment