private void lstItems_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListBox list = sender as ListBox; if (this.IsInitialized && list != null) { ListBoxItem selected = list.SelectedItem as ListBoxItem; if (selected != null) { string value = (string)selected.Content; this.lblOptions.Content = string.Concat(value, " Options"); OptionsControl panel = this.GetControl(value); if (panel != null) { if (panel.Configuration == null) { panel.SetConfiguration(_configuration); } if (_openPanel != null) { _openPanel.Visibility = System.Windows.Visibility.Collapsed; } panel.Visibility = System.Windows.Visibility.Visible; _openPanel = panel; } } } }