protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Commands); // Simple command ------------------------------------------- SimpleCommandButton.SetCommand(Vm.SayHelloCommand); // Command and checkbox --------------------------------- MyCheckBox.SetCommand(Vm.SayHelloCommand); // Command and custom event ----------------------------- CustomEventEditText.SetCommand <string, View.FocusChangeEventArgs>( "FocusChange", Vm.ShowMessageCommand, "This message shows on FocusChange"); // Command and static parameter ----------------------------- StaticParameterButton.SetCommand( Vm.ShowMessageCommand, "Hello Evolve, this is a static message!"); // Command and dynamic parameter ---------------------------- var parameterBinding = this.SetBinding(() => MyEditText.Text); _bindings.Add(parameterBinding); DynamicParameterButton.SetCommand(Vm.ShowMessageCommand, parameterBinding); // Subscribing to events to avoid linker issues in release mode --------------------------------- // This "fools" the linker into believing that the events are used. // In fact we don't even subscribe to them. // See https://developer.xamarin.com/guides/android/advanced_topics/linking/ if (_falseFlag) { SimpleCommandButton.Click += (s, e) => { }; StaticParameterButton.Click += (s, e) => { }; DynamicParameterButton.Click += (s, e) => { }; MyCheckBox.CheckedChange += (s, e) => { }; CustomEventEditText.FocusChange += (s, e) => { }; } }
public override void ViewDidLoad() { base.ViewDidLoad(); var nextButton = new UIBarButtonItem( "Next", UIBarButtonItemStyle.Plain, (s, e) => { Nav.NavigateTo(AppDelegate.CommandsPage2Key); }); NavigationItem.SetRightBarButtonItem(nextButton, false); // Simple command ------------------------------------------- SimpleCommandButton.SetCommand(Vm.SayHelloCommand); // Command and checkbox --------------------------------- MySwitch.SetCommand(Vm.SayHelloCommand); // Command and static parameter ----------------------------- StaticParameterButton.SetCommand( Vm.ShowMessageCommand, "Hello Evolve, this is a static message!"); // Subscribing to events to avoid linker issues in release mode --------------------------------- // This "fools" the linker into believing that the events are used. // In fact we don't even subscribe to them. // See https://developer.xamarin.com/guides/android/advanced_topics/linking/ if (_falseFlag) { SimpleCommandButton.TouchUpInside += (s, e) => { }; StaticParameterButton.TouchUpInside += (s, e) => { }; MySwitch.ValueChanged += (s, e) => { }; } }