Hi everyone,
Currently in my application, when i build the page toolbar using my ViewModel, i've two way to do this:
// Attached to a ViewModel Action (public method)
var item= new ToolbarItem("Save", "ic_menu_save", async() => await _MyViewModel.Save());
or
// Attached to a ViewModel Command
var item= new ToolbarItem("Save", "ic_menu_save", () => {});
item.BindingContext = _MyViewModel;
item.SetBinding(ToolbarItem.CommandProperty, "SaveCommand");
First, am i doing this correctly ? Is there another way to achieve that ?
Secondly, am i the only one thinking that having a Command parameter in the ToolbarItem would be nice ? like this:
var item= new ToolbarItem("Save", "ic_menu_save", _MyViewModel.SaveCommand);
I usually use command to do action in my page with controls, so i'd like to do the same with the toolbar, but i don't like the way i do it with an empty action (action cannot be null in the constructor) and a binding after.
I'm just wondering if there's another way to achieve this, or if the XamarinForms team will add think about it someday.
Thanks,
Best regards,
Armand