示例#1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.AddComment);

            // Retrieve navigation parameter and set as current "DataContext"
            Vm = GlobalNavigation.GetAndRemoveParameter <FlowerViewModel>(Intent);

            // Avoid aggressive linker problem which removes the TextChanged event
            CommentText.TextChanged += (s, e) =>
            {
            };

            _saveBinding = this.SetBinding(
                () => CommentText.Text);

            // Avoid aggressive linker problem which removes the Click event
            SaveCommentButton.Click += (s, e) =>
            {
            };

            SaveCommentButton.SetCommand(
                "Click",
                Vm.SaveCommentCommand,
                _saveBinding);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.AddComment);

            // Retrieve navigation parameter and set as current "DataContext"
            Vm = GlobalNavigation.GetAndRemoveParameter <FlowerViewModel>(Intent);

            _saveBinding = this.SetBinding(() => CommentText.Text);

            SaveCommentButton.SetCommand(
                Vm.SaveCommentCommand,
                _saveBinding);

            // 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)
            {
                SaveCommentButton.Click += (s, e) => { };
                CommentText.TextChanged += (s, e) => { };
            }
        }
        public override void ViewDidLoad()
        {
            View = new UniversalView();
            base.ViewDidLoad();
            InitializeComponent();

            Title = "Add comment";

            _commentBinding = this.SetBinding(
                () => CommentText.Text)
                              .UpdateSourceTrigger("Changed");

            SaveCommentButton.SetCommand("Clicked", Vm.SaveCommentCommand, _commentBinding);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.AddComment);

            // Retrieve navigation parameter and set as current "DataContext"
            Vm = GlobalNavigation.GetAndRemoveParameter <FlowerViewModel>(Intent);

            _saveBinding = this.SetBinding(
                () => CommentText.Text);

            SaveCommentButton.SetCommand(
                "Click",
                Vm.SaveCommentCommand,
                _saveBinding);
        }