Question

I'm installing new menu items by installing new vsix packages. Here is what I've got: screenshot

I tried to change different values to make VS sort my menu items, but no luck. Here is part of my .vsct file:

<Buttons>
  <Button guid="guidWizardPackage2010Project" id="AddImpl" priority="0x0301" type="Button">
    <Parent guid="guidWizardPackage2010Project" id="MyMenuGroup" />
    <Icon guid="guidImages" id="logo" />
    <CommandFlag>DynamicVisibility</CommandFlag>
    <Strings>
      <CommandName>Add Implementation [VER]...</CommandName>
      <ButtonText>Add Implementation [VER]...</ButtonText>
    </Strings>
  </Button>
</Buttons>

...

<GuidSymbol name="guidVSPackage2012Pkg" value="{random generated}" />
<GuidSymbol name="guidWizardPackage2010Project" value="{random generated}">
  <IDSymbol name="MyMenuGroup" value="0x1020" />
  <IDSymbol name="AddImpl" value="0x0100" />
</GuidSymbol>

I tried to increment such values like "MyMenuGroup" value, "AddImpl" value, guids, priority="0x0301" in hope one of them is used for sorting, but they not.

I can customize the order manually but they should be sorted just after installing.

Is there any way to customize or sort menu items programmatically (automatically)?

Était-ce utile?

La solution

Here is my complicated solution (run from Package.Initialize()):

        DTE2 dte = GetGlobalService(typeof (DTE)) as DTE2;
        CommandBars commandBars = (CommandBars) dte.CommandBars;
        CommandBar projectMenu = commandBars["Project"];

        CommandBarControl control = null;
        foreach (CommandBarControl barControl in projectMenu.Controls)
            if (...) // currently added control
            {
                control = barControl;
            }
                // finding new position for the control
        control.Move(projectMenu, newPosition); // move control to correct place
        control.BeginGroup = false;             // remove ugly separator above

I have many controls so they should not run this code simultaneously, just the last one. I hope you have better answer.

Autres conseils

The priority property is the one that controls relative order of your menu items. Strange that it doesn't work for you.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top