Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Append to CommandBar.PrimaryCommands #15

Closed
allan2 opened this issue Jul 5, 2021 · 4 comments
Closed

Append to CommandBar.PrimaryCommands #15

allan2 opened this issue Jul 5, 2021 · 4 comments
Labels
question Further information is requested

Comments

@allan2
Copy link

allan2 commented Jul 5, 2021

Is there a way to add items to the PrimaryCommands collection?

let cmd_bar = CommandBar::new()?;
let add_btn = AppBarButton::new()?;
let add_icon = SymbolIcon::new()?;
add_icon.SetSymbol(Symbol::Add)?;
add_btn.SetLabel("Add Task")?;
add_btn.SetIcon(add_icon)?;
cmd_bar.PrimaryCommands()?.Add(add_btn)?; // something like this

[1] WinUI 3 docs on CommandBar
[2] WinUI 3 docs on PrimaryCommands

@kennykerr
Copy link
Collaborator

I'm sorry I don't have any experience with the WinUI APIs. You may want to ask API-specific questions on the WinUI repo:

https://github.com/microsoft/microsoft-ui-xaml

@kennykerr kennykerr added the question Further information is requested label Jul 6, 2021
@riverar
Copy link
Collaborator

riverar commented Jul 6, 2021

Hey @allan2, I believe there are still a few quirks to iron out with dependency tracking (@kennykerr?).

If you add Windows::Foundation::Collections::IObservableVector to your build! macro explicitly, Append and other methods should be visible.

image

@kennykerr
Copy link
Collaborator

Yes, dependencies that involve generic interfaces, such as IObservableVector<T>, are not correctly tracked. Here's the issue for that: microsoft/windows-rs#772

@allan2
Copy link
Author

allan2 commented Jul 6, 2021

Awesome. That worked. Thanks @riverar @kennykerr!

@allan2 allan2 closed this as completed Jul 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants