title: Referencing nested properties in XAML
body: <p>This question may be a duplicate of <a href="https://stackoverflow.com/questions/4269896/creating-an-instance-of-a-nested-class-in-xaml">Creating an instance of a nested class in XAML</a>.  This question and the related MSDN documentation are concerned with nested types.  In this example, the types themselves are not nested, but the syntax seems familiar.  Whether that justifies a separate question and answer is unknown to me.</p>
  
  <p>I would like to access a nested property using an <code>ObjectDataProvider</code>.  I can access a static property on a type, but accessing an instance property through a static property on a type results in compilation errors.</p>
  
  <p>For example, take the following three classes.</p>
  
  <pre><code>public static class A
  {
     static A()
     {
        BProperty = new B();
     }
  
     public static B BProperty { get; private set; }
  }
  
  public class B
  {
     public B()
     {
        CProperty = new C();
     }
  
     public C CProperty { get; private set; }
  
     public string GetValue(string arg)
     {
        return arg + " from B";
     }
  }
  
  public class C
  {
     public string GetValue(string arg)
     {
        return arg + " from C";
     }
  }
  </code></pre>
  
  <p>Creating an <code>ObjectDataProvider</code> for <code>BProperty</code> on <code>A</code> can be accomplished using the following XAML.</p>
  
  <pre><code>&lt;Window.Resources&gt;
     &lt;ObjectDataProvider x:Key="provider"
                         ObjectInstance="{x:Static Member=local:A.BProperty}"
                         MethodName="GetValue"&gt;
        &lt;ObjectDataProvider.MethodParameters&gt;
           &lt;System:String&gt;string argument&lt;/System:String&gt;
        &lt;/ObjectDataProvider.MethodParameters&gt;
     &lt;/ObjectDataProvider&gt;
  &lt;/Window.Resources&gt;
  &lt;Grid&gt;
     &lt;Label Content="{Binding Source={StaticResource provider}}" /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>Running this code produces a label with the text: "string argument from B".</p>
  
  <p>If I set <code>provider</code>'s <code>ObjectInstance</code> to <code>"{x:Static Member=local:A.BProperty.CProperty}"</code> or <code>"{x:Static Member=local:A.BProperty+CProperty}"</code> I receive compilation errors.</p>
  
  <p>How can I access <code>CProperty</code> on <code>A</code>'s instance of <code>BProperty</code> from the <code>ObjectDataProvider</code>?</p>