Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Add item properties in Visual Studio 2019 project system

$
0
0

I am trying to add properties to an item type in a custom Visual Studio 2019 project. I am using the new CPS project system and created a Package. CPS supports Xaml Rule files for hooking up item properties but this system is just not going to work for my solution because they are static rules.

I need to show different properties for a single item type based on another property. It is a similar functionality that used to be in XNA and I also had this working in the old project system like 10 years ago. For example, I have Content item types but one item has a property Type=A, so it has one string property, another Content item had Type=1, so it has one integer property.

I have tried using EnvDTE.IExtenderProvider but after following code samples my provider is never called. I believe this is because it is no longer supported in VS 2019. The page for EnvDTE.IExtenderProvider does not list it, only 2015 and 2017.

Another solution I have tried is swapping out the Property Browser with a custom control but my custom property control is only swapped out when I focus a custom tool box window. I created a MyPropertyBrowser and inside MyToolWindow I hook up the browser object.

Dim trackSel = CType(GetService(GetType(SVsTrackSelectionEx)), IVsTrackSelectionEx)
Dim guidBrowser = GetType(MyPropertyBrowser).GUID.ToString("B")
trackSel.OnElementValueChange(CUInt(VSConstants.VSSELELEMID.SEID_PropertyBrowserSID), 0, guidBrowser)

Inside MyPropertyBrowser I use SVsShellMonitorSelection.GetCurrentSelection to get the selected item. Is there a way to get MyPropertyBrowser to show without a custom tool box window? I suspect it is not possible because of the scope of SVsTrackSelectionEx, and it must be called from within the solution explorer.

Alternatively, is there a way to update the property browser when certain items are selected in the solution explorer? Possibly some way to add properties once a selection is detected.



Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>