title: WPF code to turn visibility off:on of multiple stackpanels
body: <p>I have multiple stackpanels that are collapsed at first and as a button is clicked the stackpanel relating to the button click becomes visible. As off right now this is what I have that works.</p>
  
  <pre><code>private void Button1_Click(object sender, RoutedEventArgs e)
      {
          dgrid.ItemsSource = FillDataGrid("ShipWorksConnection", "GetPicklistItems", "PickList"); 
  
          SP1.Visibility = Visibility.Visible;            
          SP2.Visibility = Visibility.Collapsed;
          SP3.Visibility = Visibility.Collapsed;
          SP4.Visibility = Visibility.Collapsed;
  
      }
  private void Button2_Click(object sender, RoutedEventArgs e)
      {
          dgrid.ItemsSource = FillDataGrid("SupplyConnection", "GetAllSupplies", "Supplies"); 
  
          SP1.Visibility = Visibility.Collapsed;
          SP2.Visibility = Visibility.Visible;
          SP3.Visibility = Visibility.Collapsed;
          SP4.Visibility = Visibility.Collapsed;
  
      }
  </code></pre>
  
  <p>and so on for multiple button click events. Is this the way to handle this and since I'll be adding more button click events is there something else I could do to make the code more reusable. </p>