示例#1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var label = new UILabel(new CGRect(10, 100, 300, 30));

            label.Text = "Do these update?";
            Add(label);
            var label2 = new UILabel(new CGRect(10, 130, 300, 30));

            label2.BackgroundColor = UIColor.Yellow;
            Add(label2);
            var label3 = new UILabel(new CGRect(10, 160, 300, 30));

            label3.BackgroundColor = UIColor.Cyan;
            Add(label3);

            var p1 = new PersonUIView();

            p1.Frame           = new CGRect(10, 200, 300, 40);
            p1.BackgroundColor = UIColor.Yellow;
            Add(p1);

            var p2 = new PersonUIView();

            p2.Frame           = new CGRect(10, 250, 300, 40);
            p2.BackgroundColor = UIColor.Cyan;
            Add(p2);

            var set = this.CreateBindingSet <ContainsSubView, ContainsSubViewModel>();

            set.Bind(label2).To("FirstPerson.FirstName + ' ' + FirstPerson.LastName");
            set.Bind(label3).To("SecondPerson.FirstName + ' ' + SecondPerson.LastName");
            set.Bind(p1).For(p => p.DataContext).To(vm => vm.FirstPerson);
            set.Bind(p2).For(p => p.DataContext).To(vm => vm.SecondPerson);
            set.Apply();

            var gesture = new UITapGestureRecognizer(() =>
            {
                p1.ResignFirstResponders();
                p2.ResignFirstResponders();
            });

            View.AddGestureRecognizer(gesture);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var label = new UILabel(new CGRect(10, 100, 300, 30));
            label.Text = "Do these update?";
            Add(label);
            var label2 = new UILabel(new CGRect(10, 130, 300, 30));
            label2.BackgroundColor = UIColor.Yellow;
            Add(label2);
            var label3 = new UILabel(new CGRect(10, 160, 300, 30));
            label3.BackgroundColor = UIColor.Cyan;
            Add(label3);

            var p1 = new PersonUIView();
            p1.Frame = new CGRect(10, 200, 300, 40);
            p1.BackgroundColor = UIColor.Yellow;
            Add(p1);

            var p2 = new PersonUIView();
            p2.Frame = new CGRect(10, 250, 300, 40);
            p2.BackgroundColor = UIColor.Cyan;
            Add(p2);

            var set = this.CreateBindingSet<ContainsSubView, ContainsSubViewModel>();
            set.Bind(label2).To("FirstPerson.FirstName + ' ' + FirstPerson.LastName");
            set.Bind(label3).To("SecondPerson.FirstName + ' ' + SecondPerson.LastName");
            set.Bind(p1).For(p => p.DataContext).To(vm => vm.FirstPerson);
            set.Bind(p2).For(p => p.DataContext).To(vm => vm.SecondPerson);
            set.Apply();

            var gesture = new UITapGestureRecognizer(() =>
            {
                p1.ResignFirstResponders();
                p2.ResignFirstResponders();
            });
            View.AddGestureRecognizer(gesture);
        }