public override void Execute(object parameter) { // Create UI control configureControlsControl = new ConfigureControlsControl(); // Create view model that interacts with UI and associate it as the data context so all elements // of the UI can use XAML binding to utilize the view model. ConfigureControlsViewModel vm = new ConfigureControlsViewModel(); IApplicationAdmin appAdmin = MapApplication.Current as IApplicationAdmin; if (appAdmin != null && appAdmin.ConfigurableControls != null) { // Process each element in the configurable controls collection, looking for those that support configuration foreach (FrameworkElement elem in appAdmin.ConfigurableControls) { if (string.IsNullOrWhiteSpace(elem.Name)) { continue; } ISupportsConfiguration supportsConfig = elem as ISupportsConfiguration; if (supportsConfig != null) { string displayName = ElementExtensions.GetDisplayName(elem); ConfigureControlDataItem ccdi = new ConfigureControlDataItem() { Label = displayName ?? elem.Name.InsertSpaces(), Element = elem }; // Add this element to the list within the view model vm.ConfigurableItems.Add(ccdi); } } } // Associate close command with method that will hide the UI vm.Closed += new System.EventHandler(vm_Closed); // Assign view model as data context for UI configureControlsControl.DataContext = vm; // Display UI BuilderApplication.Instance.ShowWindow(ESRI.ArcGIS.Mapping.Builder.Resources.Strings.ConfigureControls, configureControlsControl, true); }
public override void Execute(object parameter) { // Create UI control configureControlsControl = new ConfigureControlsControl(); // Create view model that interacts with UI and associate it as the data context so all elements // of the UI can use XAML binding to utilize the view model. ConfigureControlsViewModel vm = new ConfigureControlsViewModel(); IApplicationAdmin appAdmin = MapApplication.Current as IApplicationAdmin; if (appAdmin != null && appAdmin.ConfigurableControls != null) { // Process each element in the configurable controls collection, looking for those that support configuration foreach (FrameworkElement elem in appAdmin.ConfigurableControls) { if (string.IsNullOrWhiteSpace(elem.Name)) continue; ISupportsConfiguration supportsConfig = elem as ISupportsConfiguration; if (supportsConfig != null) { string displayName = ElementExtensions.GetDisplayName(elem); ConfigureControlDataItem ccdi = new ConfigureControlDataItem() { Label = displayName ?? elem.Name.InsertSpaces(), Element = elem }; // Add this element to the list within the view model vm.ConfigurableItems.Add(ccdi); } } } // Associate close command with method that will hide the UI vm.Closed += new System.EventHandler(vm_Closed); // Assign view model as data context for UI configureControlsControl.DataContext = vm; // Display UI BuilderApplication.Instance.ShowWindow(ESRI.ArcGIS.Mapping.Builder.Resources.Strings.ConfigureControls, configureControlsControl, true); }
private static void OnSelectedIndexChanged(DependencyObject o, DependencyPropertyChangedEventArgs args) { ConfigureControlsViewModel ccvm = o as ConfigureControlsViewModel; if (ccvm == null) { return; } if (ccvm.SelectedIndex < 0 || ccvm.ConfigurableItems.Count < 1) { ccvm.SelectedItem = null; //ccvm.ConfigureEnabled = false; } else { ccvm.SelectedItem = ccvm.ConfigurableItems[ccvm.SelectedIndex]; //ccvm.ConfigureEnabled = true; } }