From fa5702cb2d0ecc18286bd3d2c4a04622f7015af2 Mon Sep 17 00:00:00 2001 From: limefrogyank Date: Mon, 24 Oct 2016 13:51:10 -0400 Subject: [PATCH] Update ToolbarRenderer.cs for CommandParameter instead of keeping the ICommand in the dictionary, keep the entire original ToolbarItem so that bindings are preserved and you can get a reference to the current CommandParameter, too. --- SecondaryToolbarDemo/iOS/ToolbarRenderer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SecondaryToolbarDemo/iOS/ToolbarRenderer.cs b/SecondaryToolbarDemo/iOS/ToolbarRenderer.cs index daffca0..2661196 100644 --- a/SecondaryToolbarDemo/iOS/ToolbarRenderer.cs +++ b/SecondaryToolbarDemo/iOS/ToolbarRenderer.cs @@ -15,7 +15,7 @@ public class ToolbarRenderer : PageRenderer { UIToolbar _toolbar; List _secondaryItems; - readonly Dictionary _buttonCommands = new Dictionary (); + readonly Dictionary _buttonCommands = new Dictionary (); protected override void OnElementChanged (VisualElementChangedEventArgs e) { @@ -41,7 +41,7 @@ public override void ViewWillAppear (bool animated) button = Enum.TryParse (systemItemName, out systemItem) ? new UIBarButtonItem (systemItem, ToolClicked) : new UIBarButtonItem (tool.Text, UIBarButtonItemStyle.Plain, ToolClicked); - _buttonCommands.Add (button, tool.Command); + _buttonCommands.Add (button, tool); tools.Add (button); } @@ -56,8 +56,8 @@ public override void ViewWillAppear (bool animated) void ToolClicked(object sender, EventArgs args) { var tool = sender as UIBarButtonItem; - var command = _buttonCommands [tool]; - command.Execute (null); + var command = _buttonCommands[tool].Command; + command.Execute(_buttonCommands[tool].CommandParameter); } public override void ViewWillDisappear (bool animated)