Add an API to allow _any_ command to be pinned

This commit is contained in:
Mike Griese
2026-02-05 16:22:32 -06:00
parent 965520ffe6
commit 01164b33ec
4 changed files with 31 additions and 0 deletions

View File

@@ -2061,6 +2061,7 @@ bands via the new `DockBand` property on `ICommandProvider3`.
interface ICommandProvider3 requires ICommandProvider2
{
ICommandItem[] GetDockBands();
ICommandItem GetCommandItemById(String id);
};
```

View File

@@ -188,4 +188,14 @@ public partial class AllAppsCommandProvider : CommandProvider
{
RaiseItemsChanged(0);
}
public override ICommandItem? GetCommandItemById(string id)
{
if (id == _listItem.Command.Id)
{
return _listItem;
}
return _page.GetAppCommandItemById(id);
}
}

View File

@@ -205,4 +205,19 @@ public sealed partial class AllAppsPage : ListPage
RaiseItemsChanged(0);
}
internal ICommandItem? GetAppCommandItemById(string id)
{
var items = this.GetItems();
foreach (var item in items)
{
if (item.Command.Id == id)
{
return item;
}
}
return null;
}
}

View File

@@ -56,6 +56,11 @@ public abstract partial class CommandProvider :
return null;
}
public virtual ICommandItem? GetCommandItemById(string id)
{
return null;
}
/// <summary>
/// This is used to manually populate the WinRT type cache in CmdPal with
/// any interfaces that might not follow a straight linear path of requires.