title: Alternate way to display usercontrols in wpf
body: <p>I'd like to know if there is an alternate way to display <code>usercontrols</code> inside <code>mainwindow</code> in WPF application. 
  Currently I make use of the visibility property of <code>usercontrols</code> to display one usercontrol at a time on a button click. I set the visibility of the usercontrols to <code>Hidden</code> and on button clicks I change the visibility. It works perfectly. But is this the correct way to do this? </p>
  
  <p>EDIT:</p>
  
  <p>I tried something like this but it does not work.</p>
  
  <pre><code>mainwindow.xaml:
  
  &lt;Window x:Class="WpfApplication4.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:WpfApplication4"
      Title="MainWindow" Height="350" Width="525"&gt;
  &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="54*" /&gt;
          &lt;RowDefinition Height="257*" /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid Grid.Row="1"&gt;
          &lt;ContentControl Content="{Binding CurrentView}"/&gt;
      &lt;/Grid&gt;
      &lt;Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="25,12,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /&gt;
      &lt;Button Content="Button" Height="23" HorizontalAlignment="Right" Margin="0,12,251,0" Name="button2" VerticalAlignment="Top" Width="75" /&gt;
  &lt;/Grid&gt;
  
  &lt;/Window&gt;
  </code></pre>
  
  <p>There are two user controls namely-UserControl1 and UserControl2. In the code behind:</p>
  
  <pre><code> private UserControl currentview;
  
  
      private UserControl CurrentView
      {
          get
          {
              return this.currentview;
          }
          set
          {
              this.currentview = value;
              //RaisePropertyChanged("CurrentView");
          }
      }
  
      private void button1_Click(object sender, RoutedEventArgs e)
      {
          UserControl1 uc1 = new UserControl1();
          CurrentView = uc1;
      }
  </code></pre>
  
  <p>It does not work. What is the right way to do it?</p>