title: Refresh WPF UserControl via XAML
body: <p>I'm using WPF within Visual Studio 2008. I have a simple WPF UserControl with the following code:</p>
  
  <pre><code>  public partial class UserControl1 : UserControl
    {
      public UserControl1()
      {
        InitializeComponent();
        Composite = new Composite();
      }
  
      protected override void OnRender(DrawingContext drawingContext)
      {
        //LayoutRoot is name of default Grid instance
        if (!LayoutRoot.Children.Contains(Composite))
        {
          LayoutRoot.Children.Add(Composite);
        }
      }
  
      public Composite Composite
      {
        get;
        set;
      }
    }
  
    public class Composite : ContentControl
    {
      protected override void OnRender(DrawingContext drawingContext)
      {
        drawingContext.DrawRectangle(new SolidColorBrush(Color), new Pen(Brushes.Black, 1.0), new Rect(RenderSize));
      }
  
      public Color Color
      {
        get;
        set;
      }
    }
  </code></pre>
  
  <p>I then use this UserControl in a WPF application, the XAML of the page looking like this:</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication1.Window1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:test="clr-namespace:WpfControlLibrary1;assembly=WpfControlLibrary1"
      Title="Window1" Height="500" Width="700" Background="AliceBlue"&gt;
    &lt;test:UserControl1 Name="uControl1"&gt;
      &lt;test:UserControl1.Composite&gt;
        &lt;test:Composite Color="Green"/&gt;
      &lt;/test:UserControl1.Composite&gt;
    &lt;/test:UserControl1&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>My question is: what code do I have to add to the above so that by changing "Composite Color" to something other than Green and hitting the return button, the UserControl automatically refreshes? The behaviour I'm looking for is what happens when you change the Background of Window1 to a color other than AliceBlue and hit return.</p>
  
  <p>When I run the code the correct color is seen, the problem is with the refresh at designtime via XAML.</p>
  
  <p>Many thanks for any pointers which help me understand what is going on here!</p>