Creating an instance of a nested class in XAML

Pragmateek picture Pragmateek · Nov 24, 2010 · Viewed 12.2k times · Source

in a XAML file (a WPF UserControl), is there a way to reference an inner class "B" defined in another class "A" ?

public class A
{
    public class B
    {
    }
}

Something like :

<local:A.B ... />

This syntax does not work because "B" is interpreted as a property named "B" in class "A".

I've tried more exotic syntaxes like "::" or "+" but none seems to work.

I'm currently using Silverlight 4 with VS2010.

Thanks in advance for your help.

Answer

Ludovic Chabant picture Ludovic Chabant · Nov 14, 2012

This question is pretty old, and I don't know if it would have worked with the version of WPF back in 2010, but now you can make it work by using the "real" (internal) name of the nested type:

<local:A+B />

If you've ever looked a disassembled code, that's how nested types look like:

ParentTypeName+Nested