title: Change content stack panel dynamically with button click WPF
body: <p>I would like to change stack panel content/data on button click in the same window.</p>
  
  <p>I have a menu list on left and on the right of the window I have 2 stackpanel which I want to update. This is actually my configuration screen. Following is my XAML code:</p>
  
  <pre><code>&lt;Window x:Class="Manager.Screens.Configurations"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:local="clr-namespace:Manager.Screens"
          mc:Ignorable="d"
          Title="Configurations" Height="850" Width="1000" WindowStyle="None" &gt;
  
      &lt;Border 
            BorderBrush="Black" 
            BorderThickness="0" 
            Padding="0"&gt;
          &lt;Grid Background="White" ShowGridLines="True" Margin="-3,0,0,0"&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="200*"/&gt;
                  &lt;ColumnDefinition Width="263*"/&gt;
                  &lt;ColumnDefinition Width="Auto"/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
  
              &lt;StackPanel Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Name="StackPanel1" VerticalAlignment="Top" Height="Auto" Width="Auto"&gt;
                  &lt;Image Source="Resources\Images\config_back.jpg" Stretch="Fill" Opacity="0.65" Height="Auto" Margin="-3,-2,0,0"/&gt;
                  &lt;Button Margin="0,-1450,0,60" Height="38" Background="Transparent"&gt;
                      &lt;StackPanel Orientation="Horizontal" Width="332"&gt;
                          &lt;Image Source="Resources\Images\tools.png" Margin="75,0,25,0"/&gt;
                          &lt;TextBlock Text="General" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Foreground="#FFFF8C3D"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/Button&gt;
                  &lt;Button Margin="0,-1350,0,10" Height="38" Background="Transparent"&gt;
                      &lt;StackPanel Orientation="Horizontal" Width="332"&gt;
                          &lt;Image Source="Resources\Images\setting.png" Margin="75,0,25,0"/&gt;
                          &lt;TextBlock Text="Settings" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Foreground="#FFFF8C3D"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/Button&gt;
                  &lt;Button Margin="0,-1250,0,-40" Height="38" Background="Transparent"&gt;
                      &lt;StackPanel Orientation="Horizontal" Width="332"&gt;
                          &lt;Image Source="Resources\Images\user.png" Margin="75,0,25,0"/&gt;
                          &lt;TextBlock Text="Limits/Stations" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Foreground="#FFFF8C3D"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/Button&gt;
                  &lt;Button Margin="0,-1150,0,-90" Height="38" Background="Transparent"&gt;
                      &lt;StackPanel Orientation="Horizontal" Width="332"&gt;
                          &lt;Image Source="Resources\Images\user.png" Margin="75,0,25,0"/&gt;
                          &lt;TextBlock Text="Portions" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Foreground="#FFFF8C3D"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/Button&gt;
                  &lt;Button Margin="0,-1050,0,-140" Height="38" Background="Transparent"&gt;
                      &lt;StackPanel Orientation="Horizontal" Width="332"&gt;
                          &lt;Image Source="Resources\Images\user.png" Margin="75,0,25,0"/&gt;
                          &lt;TextBlock Text="Label Templates" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Foreground="#FFFF8C3D"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/Button&gt;
  
                  &lt;Button Margin="0,-950,0,-190" Height="38" Background="Transparent"&gt;
                      &lt;StackPanel Orientation="Horizontal" Width="332"&gt;
                          &lt;Image Source="Resources\Images\user.png" Margin="75,0,25,0"/&gt;
                          &lt;TextBlock Text="RFID Containers" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Foreground="#FFFF8C3D"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/Button&gt;
                  &lt;Button Margin="0,-850,0,-240" Height="38" Background="Transparent"&gt;
                      &lt;StackPanel Orientation="Horizontal" Width="332"&gt;
                          &lt;Image Source="Resources\Images\user.png" Margin="75,0,25,0"/&gt;
                          &lt;TextBlock Text="User Management" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Foreground="#FFFF8C3D"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/Button&gt;
              &lt;/StackPanel&gt;
  
              &lt;StackPanel Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" Name="StackPanel2" VerticalAlignment="Top" Orientation="Vertical"&gt;
  
              &lt;/StackPanel&gt;
  
              &lt;StackPanel Grid.Column="2" Grid.Row="0" HorizontalAlignment="Left" Name="StackPanel3" VerticalAlignment="Top"&gt;
                  &lt;TextBlock FontSize="18" HorizontalAlignment="Center" Margin="0,0,0,15"&gt;StackPanel3&lt;/TextBlock&gt;
                  &lt;Button Margin="10"&gt;Button 7&lt;/Button&gt;
                  &lt;Button Margin="10"&gt;Button 8&lt;/Button&gt;
                  &lt;Button Margin="10"&gt;Button 9&lt;/Button&gt;
                  &lt;TextBlock&gt;ColumnDefinition.Width="Auto"&lt;/TextBlock&gt;
                  &lt;TextBlock&gt;StackPanel.HorizontalAlignment="Left"&lt;/TextBlock&gt;
                  &lt;TextBlock&gt;StackPanel.VerticalAlignment="Top"&lt;/TextBlock&gt;
                  &lt;TextBlock&gt;StackPanel.Orientation="Vertical"&lt;/TextBlock&gt;
                  &lt;TextBlock&gt;Button.Margin="10"&lt;/TextBlock&gt;
              &lt;/StackPanel&gt;
          &lt;/Grid&gt;
      &lt;/Border&gt;
  
  &lt;/Window&gt;
  </code></pre>
  
  <p>I haven't written any controls or functions so far please help me as I am new how can it be done in WPF.</p>