microsoft / VSExtensibility

A repo for upcoming changes to extensibility in Visual Studio, the new extensibility model, and language server protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to replace the contents of the default Properties tool window

akorchev opened this issue · comments

Hi,

I am trying to replace the contents of the Properties tool window. Something that happens for WPF components.
image
image

It seems that I should somehow use IVsTrackSelectionEx.OnElementValueChange but I couldn't make it work. After calling that method the property window contents remain the default. Via debugging I can see that the method returns 0 which indicates success. Am I missing something? Here is my code (PropertyGridToolWindow is my custom tool window that I want to replace the default and its guid is GuidList.PropertyGrid):

 var frame = await _package.ShowToolWindowAsync(typeof(PropertyGridToolWindow), 0, true, _package.DisposalToken);

 if (frame is PropertyGridToolWindow propertyGrid)
 {
   var styles = await Task.WhenAll(selectedObjects.Select(c => _content.GetStyleAsync(c.Path)));

   propertyGrid.SetSelection(selectedObjects, styles);
 }

 _content.UpdateSelection(selection);

 var trackSelectionEx = (IVsTrackSelectionEx)GetService(typeof(SVsTrackSelectionEx));

 var result = trackSelectionEx.OnElementValueChange((uint)VSConstants.VSSELELEMID.SEID_PropertyBrowserSID, 0, GuidList.PropertyGrid);

// result is `0`

On its own my custom tool window works as expected.