views:

25

answers:

1

Is it possible to bind property of the nested class in Silverlight? I have code that looks like this:

public class A {
    public class B {
        public String Prop1 { get; set; }
    }
}

I want to assign a key for class B in xaml but I don't know how to do it. I tried something like this,

<controls:ChildWindow.Resources>
    <local:A:B x:Key="myProperty">
</controls:ChildWindow.Resources>

but it doesn't work. Any idea?

+3  A: 

From MSDN:

  • Your custom class must be public and support a default (parameterless) public constructor. (See following section for notes regarding structures.)
  • Your custom class must not be a nested class. Nested classes and the "dot" in their general CLR usage syntax interfere with other WPF and/or XAML features such as attached properties.

HTH,
Kent

Kent Boogaart