Wintellect/XamarinSamples

CommandParameter should be included in the transfer

limefrogyank opened this issue · 2 comments

I hacked it by replacing the storing of the ICommand in the Dictionary to keeping a reference to the original ToolbarItem instead.

readonly Dictionary<UIBarButtonItem, ToolbarItem> _buttonCommands = new Dictionary<UIBarButtonItem, ToolbarItem>();

In ViewWillAppear, replace the original adding to the dictionary line with:
_buttonCommands.Add(button,tool);

Then change this method to:

void ToolClicked(object sender, EventArgs args)
{
       var tool = sender as UIBarButtonItem;
       var command = _buttonCommands[tool].Command;
       command.Execute(_buttonCommands[tool].CommandParameter);
}

Seems to work ok.

FYI, thank you for this sample. It was invaluable for learning how to work with native iOS through Xamarin.Forms... especially for this iOS newbie.

Thanks. If you would like to submit a pull request with that improvement, then I'd be happy to accept it into the sample.

Thanks! Your PR was merged.