Last active
January 15, 2021 00:58
-
-
Save madskristensen/7981e3e746088b51f98c9efd13e68963 to your computer and use it in GitHub Desktop.
Shows how to add custom UIContexts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
I think finding the limitations of this term type is "trial and error", but I was able to detect
JSON
with"ActiveEditorContentType:Json"