title: How can I reuse a WPF user control but change a bound property?
body: <p>I have a WPF user control which uses a property from my viewmodel for binding. I now want to use two instances of that user control with the same viewmodel, but override the binding in one of them.</p>
  
  <p>The code looks like this</p>
  
  <p>User control</p>
  
  <pre><code>&lt;UserControl x:Class="TestWpfApp.UserControl1"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:local="clr-namespace:TestWpfApp"&gt;
      &lt;Grid&gt;
          &lt;DockPanel&gt;
              &lt;Label Margin="10" Content="{Binding MyLabel}"/&gt;
              &lt;Button Margin="10" Content="{Binding MyButton}"/&gt;
          &lt;/DockPanel&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>Main view</p>
  
  <pre><code>&lt;Window x:Class="TestWpfApp.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:local="clr-namespace:TestWpfApp"
          Title="MainWindow" Height="150" Width="525"&gt;
      &lt;Window.DataContext&gt;
          &lt;local:ViewModel/&gt;
      &lt;/Window.DataContext&gt;
      &lt;Grid&gt;
          &lt;DockPanel&gt;
              &lt;local:UserControl1 DockPanel.Dock="Top" x:Name="UserControl1"/&gt;
              &lt;!--In this instance of UserControl1, I want the Label to bind to the MyNewLabel--&gt;
              &lt;local:UserControl1 DockPanel.Dock="Top" x:Name="UserControl2"/&gt;
          &lt;/DockPanel&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Viewmodel</p>
  
  <pre><code>public class ViewModel
  {
      public string MyLabel =&gt; "Label1";
      public string MyButton =&gt; "Button1";
      public string MyNewLabel =&gt; "Label2";
  }
  </code></pre>
  
  <p>In the second instance of <code>UserControl1</code>, I would like the label to be bound to a different property. I tried setting that property as a resource on the user control, and then overriding it in the main view but I wasn't able to get that to work.</p>
  
  <p>In reality, I'm using DevExpress controls and POCO viewmodels, if that makes things easier.</p>