// Constructor public SettingsVisualHandler() { // get an instance of the MainWindow MWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); // get 'show all settings' button and click it RadioButton btnAllSettings = (RadioButton)MWindow.FindName("btnAllSettings"); //btnAllSettings.IsChecked = true; // get settings grid WrapPanel wpSettingsLeftPane = (WrapPanel)MWindow.FindName("wpSettingsLeftPane"); // get all filter buttons from the settings page List <RadioButton> _filterButtons = UIHandler.GetLogicalChildCollection <RadioButton>(wpSettingsLeftPane);//.Where(r => r.GroupName == "grpSettings").ToList(); FilterButtons = _filterButtons; // setting grid containing right hand content Grid SettingGrid = (Grid)MWindow.FindName("SettingGrid"); // get all settings panels //AllSettingPanels = UIHandler.GetLogicalChildCollection<Border>("SettingGrid").ToList(); AllSettingPanels = UIHandler.GetLogicalChildCollection <Border>(SettingGrid).ToList(); // iterate through each panel and match the border x:name to the class property name foreach (Border b in AllSettingPanels) { // remove any trailing numerals from the control name string name = StripTrailingNumerals(b.Name); // if the control name matches a property name in this class, add it to that list PropertyInfo property = typeof(SettingsVisualHandler).GetProperty(name); if (property == null) { // no property matched continue; } // add the border control to the correct List switch (property.Name) { case "MednafenPaths": MednafenPaths.Add(b); break; case "GameFolders": GameFolders.Add(b); break; case "SystemBios": SystemBios.Add(b); break; case "Netplay": Netplay.Add(b); break; case "Emulator": Emulator.Add(b); break; case "MedLaunch": MedLaunch.Add(b); break; case "Library": Library.Add(b); break; case "ScrapingSettings": ScrapingSettings.Add(b); break; default: // do nothing break; } } }