title: How can I refresh a custom wpf user control from code behind?
body: <p>I have this custom wpf user control:</p>
  
  <p><strong>ShowCustomer.xaml:</strong></p>
  
  <pre><code>&lt;UserControl x:Class="TestControlUpdate2343.Controls.ShowCustomer"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
      &lt;Grid&gt;
          &lt;TextBlock Text="{Binding Message}"/&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p><strong>ShowCustomer.xaml.cs:</strong></p>
  
  <pre><code>using System.Windows.Controls;
  using System;
  using System.ComponentModel;
  
  namespace TestControlUpdate2343.Controls
  {
      public partial class ShowCustomer : UserControl, INotifyPropertyChanged
      {
          #region ViewModelProperty: Message
          private string _message;
          public string Message
          {
              get
              {
                  return _message;
              }
  
              set
              {
                  _message = value;
                  OnPropertyChanged("Message");
              }
          }
          #endregion
  
          public ShowCustomer()
          {
              InitializeComponent();
              DataContext = this;
  
              Message = "showing test customer at: " + DateTime.Now.ToString();
          }
  
          #region INotifiedProperty Block
          public event PropertyChangedEventHandler PropertyChanged;
  
          protected void OnPropertyChanged(string propertyName)
          {
              PropertyChangedEventHandler handler = PropertyChanged;
  
              if (handler != null)
              {
                  handler(this, new PropertyChangedEventArgs(propertyName));
              }
          }
          #endregion
      }
  }
  </code></pre>
  
  <p>And I display it from this XAML:</p>
  
  <p><strong>Window1.xaml:</strong></p>
  
  <pre><code>&lt;Window x:Class="TestControlUpdate2343.Window1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:controls="clr-namespace:TestControlUpdate2343.Controls"
      Title="Window1" Height="300" Width="300"&gt;
      &lt;StackPanel HorizontalAlignment="Left" Margin="10"&gt;
          &lt;controls:ShowCustomer x:Name="ShowCustomerControl" Margin="0 0 0 10"/&gt;
          &lt;Button Content="Refresh Control" 
                  Click="Button_RefreshControls_Click"
                  Margin="0 0 0 10"/&gt;
      &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>And I would like to update the control (i.e. in this example show the current time) from my event handler in code behind:</p>
  
  <pre><code>using System.Windows;
  
  namespace TestControlUpdate2343
  {
      public partial class Window1 : Window
      {
          public Window1()
          {
              InitializeComponent();
          }
  
          private void Button_RefreshControls_Click(object sender, RoutedEventArgs e)
          {
              //ShowCustomerControl.Refresh()???
          }
      }
  }
  </code></pre>
  
  <p><strong>How can I force a refresh of my custom control from code behind, or force it to reload somehow so when I click the button it shows the current time?</strong></p>