title: XAML bind to DependencyProperty instance held in a CLR property
body: <p>How do I bind to a DependencyProperty instance that is held in a CLR property, from XAML?</p>
  
  <p>I'm trying to generate a 'settings' list (user can modify app. settings via a list of checkboxes).</p>
  
  <p>I would like the list to be dynamically created from the dependency properties in a certain class (MyOptions).  This I've achieved, I bind the ListBox to this list (which is a list of DependencyProperty objs)</p>
  
  <pre><code>public IEnumerable&lt;OptionProperty&gt; AvailableOptions
  {
      get
      {
           return from  property in GetAttachedProperties(MyOptions) 
                  where property.GetMetadata(MyOptions) is OptionPropertyMetaData
                  select new OptionProperty { OptionName = property.Name, OptionType = property.PropertyType, OptionDependencyProperty = property };
      }
  }
  </code></pre>
  
  <p>What I need to do is bind the check box in the DataTemplate (for the ListBox) to the DependencyProperty items in the list.</p>
  
  <p>So of course this isn't going to work</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;DataTemplate DataType="{x:Type local:OptionProperty}"&gt;
      &lt;Grid&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
              &lt;ColumnDefinition Width="30"&gt;&lt;/ColumnDefinition&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;TextBlock Grid.Column="0" Text="{Binding Path=OptionName}" /&gt;
          &lt;CheckBox Grid.Column="1" HorizontalAlignment="Right" IsChecked="{Binding Path=OptionDependencyProperty}"&gt;&lt;/CheckBox&gt;
      &lt;/Grid&gt;   
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>because it's just binding to the property of OptionProperty called OptionDependencyProperty, instead of the DependencyProperty that is referenced in OptionDependencyProperty.</p>
  
  <p>So how do I bind to a DependencyProperty instance that is held in a CLR property (OptionDependencyProperty), from XAML?</p>
  
  <p>I think my brain-stack is full and can't deal with the abstraction anymore :(</p>
  
  <p>Thanks!</p>