Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            try
            {
                _bindings.Add(this.SetBinding(() => MainViewModel.WelcomeTitle, () => WelcomeText.Text));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                //throw;
            }

            NavigateButton.SetCommand("Click", MainViewModel.NavigateCommand);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Binding and commanding

            // Binding between the first UILabel and the WelcomeTitle property on the VM.
            // Keep track of the binding to avoid premature garbage collection
            bindings.Add(
                this.SetBinding(
                    () => Vm.WelcomeTitle,
                    () => WelcomeText.Text));

            // Actuate the NavigateCommand on the VM.
            NavigateButton.SetCommand(
                "TouchUpInside",
                Vm.NavigateCommand);
        }
Пример #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Dismiss the keyboard
            DialogNavText.ShouldReturn += t =>
            {
                t.ResignFirstResponder();
                return(true);
            };

            // Binding and commanding

            // Binding between the first UILabel and the WelcomeTitle property on the VM.
            // Keep track of the binding to avoid premature garbage collection
            _bindings.Add(
                this.SetBinding(
                    () => Vm.WelcomeTitle,
                    () => WelcomeText.Text));

            // Actuate the IncrementCommand on the VM.
            IncrementButton.SetCommand(
                "TouchUpInside",
                Vm.IncrementCommand);

            // Create a binding that fires every time that the EditingChanged event is called
            var dialogNavBinding = this.SetBinding(
                () => DialogNavText.Text)
                                   .UpdateSourceTrigger("EditingChanged");

            // Keep track of the binding to avoid premature garbage collection
            _bindings.Add(dialogNavBinding);

            // Actuate the NavigateCommand on the VM.
            // This command needs a CommandParameter of type string.
            // This is what the dialogNavBinding provides.
            NavigateButton.SetCommand(
                "TouchUpInside",
                Vm.NavigateCommand,
                dialogNavBinding);

            // Actuate the ShowDialogCommand on the VM.
            // This command needs a CommandParameter of type string.
            // This is what the dialogNavBinding provides.
            // This button will be disabled when the content of DialogNavText
            // is empty (see ShowDialogCommand on the MainViewModel class).
            ShowDialogButton.SetCommand(
                "TouchUpInside",
                Vm.ShowDialogCommand,
                dialogNavBinding);

            // Create a binding between the Clock property of the VM
            // and the ClockText UILabel.
            // Keep track of the binding to avoid premature garbage collection
            _bindings.Add(
                this.SetBinding(
                    () => Vm.Clock,
                    () => ClockText.Text));

            // Actuate the SendMessageCommand on the VM.
            SendMessageButton.SetCommand(
                "TouchUpInside",
                Vm.SendMessageCommand);
        }