コード例 #1
0
        internal OptionPreviewControl(IServiceProvider serviceProvider, OptionStore optionStore, Func <OptionStore, IServiceProvider, AbstractOptionPreviewViewModel> createViewModel) : base(optionStore)
        {
            InitializeComponent();

            // AutomationDelegatingListView is defined in ServicesVisualStudio, which has
            // InternalsVisibleTo this project. But, the markup compiler doesn't consider the IVT
            // relationship, so declaring the AutomationDelegatingListView in XAML would require
            // duplicating that type in this project. Declaring and setting it here avoids the
            // markup compiler completely, allowing us to reference the internal
            // AutomationDelegatingListView without issue.
            var listview = new AutomationDelegatingListView();

            listview.Name              = "Options";
            listview.SelectionMode     = SelectionMode.Single;
            listview.PreviewKeyDown   += Options_PreviewKeyDown;
            listview.SelectionChanged += Options_SelectionChanged;
            listview.SetBinding(ItemsControl.ItemsSourceProperty, new Binding {
                Path = new PropertyPath(nameof(ViewModel.Items))
            });
            AutomationProperties.SetName(listview, ServicesVSResources.Options);

            listViewContentControl.Content = listview;

            _serviceProvider = serviceProvider;
            _createViewModel = createViewModel;
        }
コード例 #2
0
        internal SymbolSpecificationDialog(SymbolSpecificationViewModel viewModel)
        {
            _viewModel = viewModel;
            InitializeComponent();
            DataContext = viewModel;

            // AutomationDelegatingListView is defined in ServicesVisualStudio, which has
            // InternalsVisibleTo this project. But, the markup compiler doesn't consider the IVT
            // relationship, so declaring the AutomationDelegatingListView in XAML would require
            // duplicating that type in this project. Declaring and setting it here avoids the
            // markup compiler completely, allowing us to reference the internal
            // AutomationDelegatingListView without issue.

            symbolKindsListView = CreateAutomationDelegatingListView(nameof(SymbolSpecificationViewModel.SymbolKindList));
            symbolKindsContentControl.Content = symbolKindsListView;

            accessibilitiesListView = CreateAutomationDelegatingListView(nameof(SymbolSpecificationViewModel.AccessibilityList));
            accessibilitiesContentControl.Content = accessibilitiesListView;

            modifiersListView = CreateAutomationDelegatingListView(nameof(SymbolSpecificationViewModel.ModifierList));
            modifiersContentControl.Content = modifiersListView;

#pragma warning disable IDE0004 // Remove unnecessary cast - without the cast the delegate type would be Action<object, KeyEventArgs>.
            symbolKindsListView.AddHandler(PreviewKeyDownEvent, (KeyEventHandler)HandleSymbolKindsPreviewKeyDown, true);
            accessibilitiesListView.AddHandler(PreviewKeyDownEvent, (KeyEventHandler)HandleAccessibilitiesPreviewKeyDown, true);
            modifiersListView.AddHandler(PreviewKeyDownEvent, (KeyEventHandler)HandleModifiersPreviewKeyDown, true);
#pragma warning restore
        }
コード例 #3
0
        private static AutomationDelegatingListView CreateAutomationDelegatingListView(string itemsSourceName)
        {
            var listView = new AutomationDelegatingListView();

            listView.SelectionMode = SelectionMode.Extended;
            listView.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(itemsSourceName));
            listView.SetResourceReference(ItemsControl.ItemTemplateProperty, "listViewDataTemplate");
            return(listView);
        }