Skip to content

Instantly share code, notes, and snippets.

@yannduran
Forked from madskristensen/VSIX UIContext
Created March 24, 2019 05:55
Show Gist options
  • Save yannduran/3203b76a5b2d68bd83d8f5085f20973c to your computer and use it in GitHub Desktop.
Save yannduran/3203b76a5b2d68bd83d8f5085f20973c to your computer and use it in GitHub Desktop.
Shows how to add custom UIContexts
On the package
[ProvideAutoLoad(UIContexts.LoadContext)]
[ProvideUIContextRule(UIContexts.LoadContext,
"RightFileTypeOpen",
"(CSharpFileOpen | VBFileOpen)",
new[] { "CSharpFileOpen", "VBFileOpen" },
new[] { "ActiveEditorContentType:CSharp", "ActiveEditorContentType:Basic" })]
In the VSCT
<VisibilityConstraints>
<VisibilityItem guid="guidCmdSet" id="cmdidStuff" context=" guidLoadContext " />
</VisibilityConstraints>
<Symbols>
<GuidSymbol name="guidLoadContext" value="{C6216099-CA25-4821-A541-044E82B4DCF1}" />
</Symbols>
As a helper containing the GUIDs
namespace Foo
{
internal static class UIContexts
{
public const string LoadContext = "C6216099-CA25-4821-A541-044E82B4DCF1";
}
}
Bolded GUIDs must match
Docs on allowed conditions: https://msdn.microsoft.com/en-us/library/mt750411.aspx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment