/// <summary> /// Push properties for the selected item to the properties window. /// Note that throwing from a Windows Forms event handler would cause /// Visual Studio to crash. So if you expect your code to throw /// you should make sure to catch the exceptions you expect /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Arguments</param> private void listView1_SelectionChanged(object sender, SelectionChangedEventArgs e) { // If the change originates from us setting the selection, ignore the event if (ignoreSelectedObjectsChanges) { return; } // Create the array that will hold the properties (one set of properties per item selected) ArrayList selectedObjects = new ArrayList(); if (listView1.SelectedItems.Count > 0) { // Get the index of the selected item int index = listView1.Items.IndexOf(listView1.SelectedItems[0]); // Get the IVsWindowFrame for that item IVsWindowFrame frame = toolWindowsList[index]; // Add the properties for the selected item SelectionProperties properties = toolWindowsList.GetFrameProperties(frame); // Keeping track of the index helps us know which tool window was selected // when the change is done through the property window drop-down. properties.Index = index; // This sample only supports single selection, but if multiple // selection is supported, multiple items could be added. The // properties that they had in common would then be shown. selectedObjects.Add(properties); } // Update our selection container selectionContainer.SelectedObjects = selectedObjects; // In order to enable the drop-down of the properties window to display // all our possible items, we need to provide the list selectionContainer.SelectableObjects = toolWindowsList.WindowsProperties; // Inform Visual Studio that we changed the selection and push the new list of properties TrackSelection.OnSelectChange(selectionContainer); }