コード例 #1
0
        public PersonView()
        {
            BackgroundColor = UIColor.LightGray;

            var textFieldName = new UITextField(new RectangleF(10, 10, 320, 40));
            Add(textFieldName);
            var textFieldLastName = new UITextField(new RectangleF(10, 50, 320, 40));
            Add(textFieldLastName);

            var addressView = new AddressUIView();
            addressView.Frame = new RectangleF(10, 90, 320, 140);
            Add(addressView);

            var addressView2 = new AddressUIView();
            addressView2.Frame = new RectangleF(10, 250, 320, 140);
            addressView2.BackgroundColor = UIColor.Red;
            Add(addressView2);

            this.DelayBind(() =>
            {
                var set = this.CreateBindingSet<PersonView, PersonViewModel>();
                set.Bind(textFieldName).To(vm => vm.FirstName);
                set.Bind(textFieldLastName).To(vm => vm.LastName);
                set.Bind(addressView).For(add => add.DataContext).To(vm => vm.HomeAddress);
                set.Bind(addressView2).For(add => add.DataContext).To(vm => vm.WorkAddress);
                set.Apply();
            });
        }        
コード例 #2
0
        public PersonView()
        {
            BackgroundColor = UIColor.LightGray;

            var textFieldName = new UITextField(new RectangleF(10, 10, 320, 40));

            Add(textFieldName);
            var textFieldLastName = new UITextField(new RectangleF(10, 50, 320, 40));

            Add(textFieldLastName);

            var addressView = new AddressUIView();

            addressView.Frame = new RectangleF(10, 90, 320, 140);
            Add(addressView);

            var addressView2 = new AddressUIView();

            addressView2.Frame           = new RectangleF(10, 250, 320, 140);
            addressView2.BackgroundColor = UIColor.Red;
            Add(addressView2);

            this.DelayBind(() =>
            {
                var set = this.CreateBindingSet <PersonView, PersonViewModel>();
                set.Bind(textFieldName).To(vm => vm.FirstName);
                set.Bind(textFieldLastName).To(vm => vm.LastName);
                set.Bind(addressView).For(add => add.DataContext).To(vm => vm.HomeAddress);
                set.Bind(addressView2).For(add => add.DataContext).To(vm => vm.WorkAddress);
                set.Apply();
            });
        }