Skip to content

Commit

Permalink
Update ToolbarRenderer.cs for CommandParameter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
limefrogyank authored Oct 24, 2016
1 parent 8374224 commit fa5702c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions SecondaryToolbarDemo/iOS/ToolbarRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ToolbarRenderer : PageRenderer
{
UIToolbar _toolbar;
List<ToolbarItem> _secondaryItems;
readonly Dictionary<UIBarButtonItem, ICommand> _buttonCommands = new Dictionary<UIBarButtonItem, ICommand> ();
readonly Dictionary<UIBarButtonItem, ToolbarItem> _buttonCommands = new Dictionary<UIBarButtonItem, ToolbarItem> ();

protected override void OnElementChanged (VisualElementChangedEventArgs e)
{
Expand All @@ -41,7 +41,7 @@ public override void ViewWillAppear (bool animated)
button = Enum.TryParse<UIBarButtonSystemItem> (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);
}

Expand All @@ -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)
Expand Down

0 comments on commit fa5702c

Please sign in to comment.