Ejemplo n.º 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;
        }
Ejemplo n.º 2
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);
        }