private void Button_Click(object sender, RoutedEventArgs e) { Button getCorrectWindow = (Button)sender; switch (getCorrectWindow.Content.ToString()) { case "StackPanel": { StackPanel stackpanel = new StackPanel(); stackpanel.Show(); break; } case "Dock": { Dock dock = new Dock(); dock.Show(); break; } case "Grid": { Grid grid = new Grid(); grid.Show(); break; } case "Grid Splitter": { GridSplitter gridSplitter = new GridSplitter(); gridSplitter.Show(); break; } } }