Example #1
0
        // Initializes the view model used to represent tool configuration
        private void initConfigViewModel(string configData = null)
        {
            // Unhook event handlers if a config view model has already been initialized
            if (m_configViewModel != null)
            {
                m_configViewModel.SelectedSearchProviders.CollectionChanged -= SelectedSearchProviders_CollectionChanged;
            }

            if (configData == null)
            {
                m_configViewModel = new SearchConfigViewModel(MapApplication.Current.Map);
            }
            else
            {
                m_configViewModel = new SearchConfigViewModel(MapApplication.Current.Map, configData);
            }

            // Listen for search providers being added or removed
            m_configViewModel.SelectedSearchProviders.CollectionChanged += (o, e) =>
            {
                // Update validation state of the configuration page for selecting searches
                m_searchSelectionPage.InputValid = m_configViewModel.SelectedSearchProviders.Count > 0;

                // Update configuration wizard to reflect added and removed searches
                if (e.NewItems != null)
                {
                    addNewWizardInfo(e.NewItems, Pages);
                }

                if (e.OldItems != null)
                {
                    removeWizardPages(e.OldItems, Pages);
                }
            };

            if (m_searchSelectionPage != null && m_searchSelectionPage.Content is FrameworkElement)
            {
                ((FrameworkElement)m_searchSelectionPage.Content).DataContext = m_configViewModel;
            }
        }
        // Initializes the view model used to represent tool configuration
        private void initConfigViewModel(string configData = null)
        {
            // Unhook event handlers if a config view model has already been initialized
            if (m_configViewModel != null)
                m_configViewModel.SelectedSearchProviders.CollectionChanged -= SelectedSearchProviders_CollectionChanged;

            if (configData == null)
                m_configViewModel = new SearchConfigViewModel(MapApplication.Current.Map);
            else
                m_configViewModel = new SearchConfigViewModel(MapApplication.Current.Map, configData);

            // Listen for search providers being added or removed
            m_configViewModel.SelectedSearchProviders.CollectionChanged += (o, e) =>
            {
                // Update validation state of the configuration page for selecting searches
                m_searchSelectionPage.InputValid = m_configViewModel.SelectedSearchProviders.Count > 0;

                // Update configuration wizard to reflect added and removed searches
                if (e.NewItems != null)
                    addNewWizardInfo(e.NewItems, Pages);

                if (e.OldItems != null)
                    removeWizardPages(e.OldItems, Pages);
            };

            if (m_searchSelectionPage != null && m_searchSelectionPage.Content is FrameworkElement)
                ((FrameworkElement)m_searchSelectionPage.Content).DataContext = m_configViewModel;
        }