コード例 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var nextButton = new UIBarButtonItem(
                "Next",
                UIBarButtonItemStyle.Plain,
                (s, e) =>
            {
                Nav.NavigateTo(AppDelegate.BindingsPage6Key);
            });

            NavigationItem.SetRightBarButtonItem(nextButton, false);

            View.AddGestureRecognizer(
                new UITapGestureRecognizer(
                    () =>
            {
                if (MyTextFieldA1.CanResignFirstResponder)
                {
                    MyTextFieldA1.ResignFirstResponder();
                }
            }));

            // Conversion back and forth --------------------------------------------------------------------

            #region Conversion back and forth

            _binding = this.SetBinding(
                () => MySwitchA1.On,
                () => MyTextFieldA1.Text,
                BindingMode.TwoWay)
                       .ConvertSourceToTarget(val => val ? "TTT" : "FFF")
                       .ConvertTargetToSource(val => val == "TTT");

            #endregion

            #region 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)
            {
                MySwitchA1.ValueChanged += (s, e) =>
                {
                };
                MyTextFieldA1.EditingChanged += (s, e) =>
                {
                };
            }

            #endregion
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var nextButton = new UIBarButtonItem(
                "Next",
                UIBarButtonItemStyle.Plain,
                (s, e) =>
            {
                Nav.NavigateTo(AppDelegate.BindingsPage3Key);
            });

            NavigationItem.SetRightBarButtonItem(nextButton, false);

            View.AddGestureRecognizer(
                new UITapGestureRecognizer(
                    () =>
            {
                if (MyTextFieldA1.CanResignFirstResponder)
                {
                    MyTextFieldA1.ResignFirstResponder();
                }
            }));

            // Bindings with custom events ------------------------------------------------------------------

            #region Bindings with custom events

            _binding = this.SetBinding(
                () => MyTextFieldA1.Text,
                () => MyLabelA1.Text)
                       .ObserveSourceEvent("EditingDidBegin");

            #endregion

            #region 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)
            {
                MyTextFieldA1.EditingChanged += (s, e) =>
                {
                };
            }

            #endregion
        }