title: Exposing property of a control inside a WPF UserControl
body: <p>I have a usercontrol which has a grid control inside</p>
  
  <pre><code> &lt;UserControl x:Class="MyGrid"&gt;
        &lt;Telerik:RadGridView EnableRowVirtualization="false"&gt; 
       &lt;/Telerik:RadGridView/&gt;
   &lt;/UserControl&gt;
  </code></pre>
  
  <p>How can I expose the EnableRowVirtualization property of the control inside the usercontrol using DependencyProperty so that when someone uses the MyGrid usercontrol,  the user will just do something like this</p>
  
  <pre><code>  &lt;grids:MyGrid  EnableRowVirtualization="false"&gt; &lt;/grids:MyGrid&gt;
  </code></pre>
  
  <p>UPDATE: Right now, this is just what I came up </p>
  
  <pre><code> public partial class MyGrid //myGrid userControl
   {
      public bool EnableRowVirtualization
      {
          get { return (bool)GetValue(EnableRowVirtualizationProperty); }
          set { SetValue(EnableRowVirtualizationProperty, value); }
      }
  
      // Using a DependencyProperty as the backing store for EnableRowVirtualization.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty EnableRowVirtualizationProperty =
          DependencyProperty.Register("EnableRowVirtualization", typeof(bool), typeof(MaxGridView), new UIPropertyMetadata(false, OnEnableRowVirtualizationPropertyChanged)
       );
  
  
      private static void OnEnableRowVirtualizationPropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
      {
          var grid = (RadGridView)depObj;
  
          if (grid != null)
          {
              grid.EnableRowVirtualization = (bool)e.NewValue;
          }
      }
  </code></pre>