title: Binding generic type ItemsControl ItemsSource in custom control to DependencyProperty
body: <p>As for question, I've created a custom <code>UserControl</code>. It has an <code>ItemsControl</code> which <code>ItemsSource</code> is binded to a property bindable as <code>DependecyProperty</code>.</p>
  <p>MyControl XAML:</p>
  <pre><code>&lt;Grid&gt;
      &lt;ItemsControl ItemsSource=&quot;{Binding Path=InternalControl}&quot; &gt;
          &lt;ItemsControl.ItemsPanel&gt;
              &lt;ItemsPanelTemplate&gt;
                  &lt;StackPanel /&gt;
              &lt;/ItemsPanelTemplate&gt;
          &lt;/ItemsControl.ItemsPanel&gt;
      &lt;/ItemsControl&gt;
  &lt;/Grid&gt;
  </code></pre>
  <p>MyControl Code:</p>
  <pre><code>    public static readonly DependencyProperty SetInternalControlProperty =
          DependencyProperty.Register(
              nameof(ObservableCollection&lt;dynamic&gt;),
              typeof(ObservableCollection&lt;dynamic&gt;),
              typeof(UtilityExpander));
  
      public ObservableCollection&lt;dynamic&gt; InternalControl
      {
          get { return (ObservableCollection&lt;dynamic&gt;)GetValue(SetInternalControlProperty); }
          set { SetValue(SetInternalControlProperty, value); }
      }
  </code></pre>
  <p>Main XAML:</p>
  <pre><code>    &lt;Controls:UtilityExpander InternalControl=&quot;{Binding GasControl}&quot;/&gt;
  </code></pre>
  <p>Main Code:</p>
  <pre><code>    private ObservableCollection&lt;UtilityGas&gt; _gasControl;
      public ObservableCollection&lt;UtilityGas&gt; GasControl { get =&gt; _gasControl; set { _gasControl = value; NotifyPropertyChanged(); } }
  </code></pre>
  <p>When running on the <code>InitializeComponent()</code> I get</p>
  <blockquote>
  <p>System.Windows.Markup.XamlParseException: 'A 'Binding' cannot be set on the 'InternalControl' property of type 'UtilityExpander'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.'</p>
  </blockquote>
  <p>The reason why I'm using <code>dynamic</code> is that I want to use the control with different type of <code>IEnumerable&lt;objects&gt;</code></p>