public OrderEditorView()
        {
            InitializeComponent();
            using (var set = new BindingSet<OrderEditorView, OrderEditorViewModel>(this))
            {
                set.Bind(dataGridView1, AttachedMembers.Object.ItemsSource)
                   .To(() => (vm, ctx) => vm.GridViewModel.ItemsSource);
                set.Bind(dataGridView1, AttachedMembers.DataGridView.SelectedItem)
                   .To(() => (vm, ctx) => vm.GridViewModel.SelectedItem)
                   .TwoWay();
                set.Bind(filterTextBox)
                   .To(() => (vm, ctx) => vm.FilterText)
                   .TwoWay();

                set.Bind(nameTextBox)
                   .To(() => (vm, ctx) => vm.Name)
                   .TwoWay()
                   .Validate();
                set.Bind(numberTextBox)
                   .To(() => (vm, ctx) => vm.Number)
                   .TwoWay()
                   .Validate();
                set.Bind(dateTimePicker1)
                   .To(() => (vm, ctx) => vm.CreationDate)
                   .TwoWay()
                   .Validate();
            }
            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.CellFormatting += DataGridView1OnCellFormatting;
        }
        public ProductWorkspaceView()
        {
            InitializeComponent();
            using (var set = new BindingSet<ProductWorkspaceView, ProductWorkspaceViewModel>(this))
            {
                set.Bind(dataGridView1, AttachedMembers.Object.ItemsSource)
                   .To(() => m => m.GridViewModel.ItemsSource);
                set.Bind(dataGridView1, AttachedMembers.DataGridView.SelectedItem)
                   .To(() => m => m.GridViewModel.SelectedItem);
                set.Bind(toolStripTextBox1)
                   .To(() => m => m.FilterText)
                   .TwoWay();

                set.Bind(saveToolStripButton)
                   .To(() => m => m.SaveChangesCommand);
                set.Bind(addToolStripButton)
                   .To(() => m => m.AddProductCommand);
                set.Bind(editToolStripButton)
                   .To(() => m => m.EditProductCommand);
                set.Bind(deleteToolStripButton)
                   .To(() => m => m.RemoveProductCommand);
                set.Bind(closeToolStripButton)
                   .To(() => m => m.CloseCommand);
            }
            dataGridView1.AutoGenerateColumns = false;
        }
        public CommandBindingView()
        {
            InitializeComponent();

            using (var set = new BindingSet<CommandBindingViewModel>())
            {
                set.Bind(canExecuteCheckBox)
                    .To(() => vm => vm.CanExecuteCommand)
                    .TwoWay();
                set.Bind(button1)
                    .To(() => vm => vm.Command)
                    .WithCommandParameter("1");
                set.Bind(button2)
                    .To(() => vm => vm.Command)
                    .ToggleEnabledState(false)
                    .WithCommandParameter("2");
                set.Bind(event1Tb, "TextChanged")
                    .ToAction(() => vm => vm.EventMethod(null));
                set.Bind(event2Tb, "TextChanged")
                    .ToAction(() => vm => vm.EventMethod(BindingSyntaxEx.Self<TextBox>().Text));
                set.Bind(event3Tb, "TextChanged")
                    .ToAction(() => vm => vm.EventMethod(BindingSyntaxEx.EventArgs<object>()));
                set.Bind(event4Tb, "TextChanged")
                    .ToAction(() => vm => vm.EventMethodMultiParams(BindingSyntaxEx.Self<TextBox>().Text, BindingSyntaxEx.EventArgs<object>()));
            }
        }
Example #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title = "Main view";
            View.BackgroundColor = UIColor.White;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Navigation", UIBarButtonItemStyle.Plain,
                                                                    (sender, args) =>
            {
                var actionSheet = new UIActionSheet("Navigation");

                actionSheet.AddButtonWithBinding("First view model modal", "Click ShowFirstWindowCommand");
                actionSheet.AddButtonWithBinding("First view model page", "Click ShowFirstPageCommand");
                actionSheet.AddButtonWithBinding("First view model tab", "Click ShowFirstTabCommand");

                actionSheet.AddButtonWithBinding("Second view model modal", "Click ShowSecondWindowCommand");
                actionSheet.AddButtonWithBinding("Second view model page", "Click ShowSecondPageCommand");
                actionSheet.AddButtonWithBinding("Second view model tab", "Click ShowSecondTabCommand");

                actionSheet.AddButtonWithBinding("Navigation (Clear back stack)", "Click ShowBackStackPageCommand");

                actionSheet.CancelButtonIndex = actionSheet.AddButton("Cancel");
                actionSheet.ShowEx(sender, (sheet, o) => sheet.ShowFrom((UIBarButtonItem)o, true));
            });


            using (var bindingSet = new BindingSet <MainViewModel>())
            {
                //TabBar
                bindingSet.Bind(this, AttachedMemberConstants.ItemsSource).To(() => (vm, ctx) => vm.ItemsSource);
                bindingSet.Bind(this, AttachedMemberConstants.SelectedItem).To(() => (vm, ctx) => vm.SelectedItem).TwoWay();
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            using (var set = new BindingSet<TabViewModel>())
            {
                NavigationItem.RightBarButtonItems = new[]
                {
                    new UIBarButtonItem {Title = "Add"}.SetBindings(set,
                        (bindingSet, item) => bindingSet.Bind(item).To(() => model => model.AddCommand)),
                    new UIBarButtonItem {Title = "Insert"}.SetBindings(set,
                        (bindingSet, item) => bindingSet.Bind(item).To(() => model => model.InsertCommand)),
                    new UIBarButtonItem {Title = "Remove"}.SetBindings(set,
                        (bindingSet, item) => bindingSet.Bind(item).To(() => model => model.RemoveCommand))
                };

                this.SetBindingMemberValue(AttachedMembers.UITabBarController.ItemTemplateSelector,
                    TabTemplateSelector.Instance);
                set.Bind(this, AttachedMemberConstants.ItemsSource).To(() => model => model.ItemsSource);
                set.Bind(this, AttachedMemberConstants.SelectedItem).To(() => model => model.SelectedItem).TwoWay();
                set.Bind(this, () => c => c.Title)
                    .To(() => m => ((ItemViewModel) m.SelectedItem).Name + " " + ((ItemViewModel) m.SelectedItem).Id)
                    .WithFallback("Nothing selected");
            }
        }
Example #6
0
        public DataAnnotationView()
        {
            InitializeComponent();
            using (var set = new BindingSet <DataAnnotationViewModel>())
            {
                set.Bind(nameTextBox)
                .To(() => (vm, ctx) => vm.NameInVm)
                .TwoWay()
                .Validate();
                set.Bind(nameErrorLabel)
                .To(() => (vm, ctx) => ctx.GetErrors(vm.NameInVm).FirstOrDefault());

                set.Bind(descriptionTextBox)
                .To(() => (vm, ctx) => vm.Description)
                .TwoWay()
                .Validate();
                set.Bind(descErrorLabel)
                .To(() => (vm, ctx) => ctx.GetErrors(vm.Description).FirstOrDefault());

                set.Bind(customErrorTextBox)
                .To(() => (vm, ctx) => vm.CustomError)
                .TwoWay();
                set.Bind(checkBox1)
                .To(() => (vm, ctx) => vm.DisableDescriptionValidation)
                .TwoWay();
                set.Bind(notValidLabel, () => t => t.Visible)
                .To(() => (vm, ctx) => !vm.IsValid);
                set.Bind(validLabel, () => t => t.Visible)
                .To(() => (vm, ctx) => vm.IsValid);
                set.Bind(summaryLabel)
                .To(() => (vm, ctx) => string.Join(Environment.NewLine, ctx.GetErrors()));
            }
        }
Example #7
0
        public void CreateBinding(GameObject obj)
        {
            _viewGameObject = obj;
            _viewCanvas     = _viewGameObject.GetComponent <Canvas>();

            var view = obj.GetComponent <MainGuiView>();

            if (view != null)
            {
                _view = view;
                Reset();                        //回滚初始值
                view.BindingContext().DataContext = this;
                return;
            }

            view  = obj.AddComponent <MainGuiView>();
            _view = view;
            view.FillField();
            view.BindingContext().DataContext = this;

            BindingSet <MainGuiView, MainGuiViewModel> bindingSet =
                view.CreateBindingSet <MainGuiView, MainGuiViewModel>();

            view.oriShowGameObjectActiveSelf = _showGameObjectActiveSelf = view.ShowGameObjectActiveSelf.activeSelf;
            bindingSet.Bind(view.ShowGameObjectActiveSelf).For(v => v.activeSelf).To(vm => vm.ShowGameObjectActiveSelf).OneWay();
            view.oriHpVal = _hpVal = view.HpVal.value;
            bindingSet.Bind(view.HpVal).For(v => v.value).To(vm => vm.HpVal).OneWay();
            view.oriHpNum = _hpNum = view.HpNum.text;
            bindingSet.Bind(view.HpNum).For(v => v.text).To(vm => vm.HpNum).OneWay();
            view.oriBulletCount = _bulletCount = view.BulletCount.text;
            bindingSet.Bind(view.BulletCount).For(v => v.text).To(vm => vm.BulletCount).OneWay();
            bindingSet.Build();

            SpriteReset();
        }
Example #8
0
 protected override void Initialize(TabPage template, BindingSet <TabPage, IViewModel> bindingSet)
 {
     bindingSet.Bind(AttachedMembers.Control.Content)
     .To(() => (vm, ctx) => vm);
     bindingSet.Bind(() => v => v.Text)
     .To(() => (vm, ctx) => ((IHasDisplayName)vm).DisplayName);
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            using (var set = new BindingSet <TabViewModel>())
            {
                NavigationItem.RightBarButtonItems = new[]
                {
                    new UIBarButtonItem {
                        Title = "Add"
                    }.SetBindings(set,
                                  (bindingSet, item) => bindingSet.Bind(item).To(() => (vm, ctx) => vm.AddCommand)),
                    new UIBarButtonItem {
                        Title = "Insert"
                    }.SetBindings(set,
                                  (bindingSet, item) => bindingSet.Bind(item).To(() => (vm, ctx) => vm.InsertCommand)),
                    new UIBarButtonItem {
                        Title = "Remove"
                    }.SetBindings(set,
                                  (bindingSet, item) => bindingSet.Bind(item).To(() => (vm, ctx) => vm.RemoveCommand))
                };

                set.Bind(this, AttachedMemberConstants.ItemsSource).To(() => (vm, ctx) => vm.ItemsSource);
                set.Bind(this, AttachedMemberConstants.SelectedItem).To(() => (vm, ctx) => vm.SelectedItem).TwoWay();
                set.Bind(this, () => controller => controller.Title).To(() => (vm, ctx) => ((ItemViewModel)vm.SelectedItem).Id);
            }
        }
        public void Clear_INotifyPropertyChangedItems_RemovesPropertyChangedEventHandlers()
        {
            var item1 = new Item();
            var item2 = new Item();
            var list  = new List <Item> {
                item1, item2, null
            };
            var bindingList = new BindingSet <Item>(list);

            Assert.Equal(1, item1.InvocationList.Length);
            Assert.Equal(1, item2.InvocationList.Length);

            bool calledListChanged = false;

            bindingList.ListChanged += (object sender, ListChangedEventArgs e) =>
            {
                calledListChanged = true;
                Assert.Equal(ListChangedType.Reset, e.ListChangedType);
                Assert.Equal(-1, e.NewIndex);
            };

            bindingList.Clear();
            Assert.True(calledListChanged);
            Assert.Empty(bindingList);

            Assert.Null(item1.InvocationList);
            Assert.Null(item2.InvocationList);
        }
Example #11
0
        public override void Bind(BindingSet <VacationRequestItemVM> bindingSet)
        {
            base.Bind(bindingSet);

            bindingSet
            .Bind(IconImage)
            .For(v => v.ImageResourceBinding())
            .To(vm => vm.Type)
            .WithConversion <VacationTypeIconImageResourceValueConverter>();

            bindingSet
            .Bind(RangeText)
            .For(v => v.TextBinding())
            .To(vm => vm.Range);

            bindingSet
            .Bind(TypeText)
            .For(v => v.TextBinding())
            .To(vm => vm.Type)
            .WithConversion <VacationTypeTitleValueConverter>();

            bindingSet
            .Bind(StateText)
            .For(v => v.TextBinding())
            .To(vm => vm.State)
            .WithConversion <VacationStateTitleValueConverter>();
        }
Example #12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor           = UIColor.White;
            CollectionView.BackgroundColor = UIColor.White;

            using (var set = new BindingSet <TableViewModel>())
            {
                NavigationItem.RightBarButtonItems = new[]
                {
                    new UIBarButtonItem {
                        Title = "Add"
                    }.SetBindings(set,
                                  (bindingSet, item) => bindingSet.Bind(item).To(() => (m, ctx) => m.AddCommand)),
                    new UIBarButtonItem {
                        Title = "Remove"
                    }.SetBindings(set,
                                  (bindingSet, item) => bindingSet.Bind(item).To(() => (m, ctx) => m.RemoveCommand))
                };

                CollectionView.SetBindingMemberValue(AttachedMembers.UICollectionView.ItemTemplateSelector,
                                                     CollectionViewCellTemplateSelector.Instance);
                set.Bind(CollectionView, AttachedMemberConstants.ItemsSource)
                .To(() => (m, ctx) => m.GridViewModel.ItemsSource);
                set.Bind(CollectionView, AttachedMemberConstants.SelectedItem)
                .To(() => (m, ctx) => m.GridViewModel.SelectedItem)
                .TwoWay();
                set.Bind(this, () => controller => controller.Title)
                .To(() => (m, ctx) => m.GridViewModel.SelectedItem.Name)
                .WithFallback("Nothing selected");
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            using (var set = new BindingSet <TabViewModel>())
            {
                NavigationItem.RightBarButtonItems = new[]
                {
                    new UIBarButtonItem {
                        Title = "Add"
                    }.SetBindings(set,
                                  (bindingSet, item) => bindingSet.Bind(item, "Clicked").To(model => model.AddCommand)),
                    new UIBarButtonItem {
                        Title = "Insert"
                    }.SetBindings(set,
                                  (bindingSet, item) => bindingSet.Bind(item, "Clicked").To(model => model.InsertCommand)),
                    new UIBarButtonItem {
                        Title = "Remove"
                    }.SetBindings(set,
                                  (bindingSet, item) => bindingSet.Bind(item, "Clicked").To(model => model.RemoveCommand))
                };

                set.Bind(this, AttachedMemberConstants.ItemsSource).To(model => model.ItemsSource);
                set.Bind(this, AttachedMemberConstants.SelectedItem).To(model => model.SelectedItem).TwoWay();
                set.BindFromExpression(this, "ItemTemplate $tabDataTemplate");
                set.BindFromExpression(this, "Title SelectedItem.Name + SelectedItem.Id, Fallback='Nothing selected'");
            }
        }
Example #14
0
        private void PrepareEditText()
        {
            var edittext = FindViewById <EditText>(Resource.Id.firstview_edittext);

            BindingSet.Bind(edittext).To(vm => vm.Hello).OneWayToSource();
            BindingSet.Apply();
        }
        protected override void Start()
        {
            this.loadingInteractionAction = new LoadingInteractionAction();
            this.toastInteractionAction   = new ToastInteractionAction(this);

            InterationViewModel viewModel = new InterationViewModel();

            this.SetDataContext(viewModel);

            /* databinding */
            BindingSet <InterationExample, InterationViewModel> bindingSet = this.CreateBindingSet <InterationExample, InterationViewModel>();

            /* Bind the method "OnOpenAlert" to an interactive request */
            bindingSet.Bind().For(v => v.OnOpenAlert(null, null)).To(vm => vm.AlertDialogRequest);

            /* Bind the ToastInteractionAction to an interactive request */
            bindingSet.Bind().For(v => v.toastInteractionAction).To(vm => vm.ToastRequest);
            /* or bind the method "OnShowToast" to an interactive request */
            //bindingSet.Bind().For(v => v.OnShowToast(null, null)).To(vm => vm.ToastRequest);

            /* Bind the LoadingInteractionAction to an interactive request */
            bindingSet.Bind().For(v => v.loadingInteractionAction).To(vm => vm.LoadingRequest);
            /* or bind the method "OnShowOrHideLoading" to an interactive request */
            //bindingSet.Bind().For(v => v.OnShowOrHideLoading(null, null)).To(vm => vm.LoadingRequest);

            /* Binding command */
            bindingSet.Bind(this.openAlert).For(v => v.onClick).To(vm => vm.OpenAlertDialog);
            bindingSet.Bind(this.showToast).For(v => v.onClick).To(vm => vm.ShowToast);
            bindingSet.Bind(this.showLoading).For(v => v.onClick).To(vm => vm.ShowLoading);
            bindingSet.Bind(this.hideLoading).For(v => v.onClick).To(vm => vm.HideLoading);

            bindingSet.Build();
        }
Example #16
0
            private BindingSet Simplify(IList <IExpression> allLhs, int lhsIndex)
            {
                if (set.Count == 0)
                {
                    return(this);
                }
                if (lhsIndex >= allLhs.Count)
                {
                    return(this);
                }
                IExpression lhs           = allLhs[lhsIndex];
                var         groups        = GroupBy(lhs);
                bool        allMatch      = true;
                BindingSet  bindingSet1   = null;
                BindingSet  newBindingSet = new BindingSet();
                BindingSet  missing       = null;
                int         count         = 0;

                foreach (var entry in groups)
                {
                    var bindingSet2 = entry.Value.Simplify(allLhs, lhsIndex + 1);
                    if (IsMissingExpr(entry.Key))
                    {
                        if (bindingSet2.set.Count > 0)
                        {
                            missing = bindingSet2;
                        }
                    }
                    else
                    {
                        count++;
                        if (bindingSet1 == null)
                        {
                            bindingSet1 = bindingSet2;
                        }
                        else if (!BindingSet.AreEqual(bindingSet1, bindingSet2, allLhs, lhsIndex + 1))
                        {
                            allMatch = false;
                        }
                    }
                    newBindingSet.set.AddRange(bindingSet2.set);
                }
                if (count == 2 && allMatch)
                {
                    newBindingSet.set.Clear();
                    foreach (Dictionary <IExpression, IExpression> dict in bindingSet1.set)
                    {
                        var dict2 = Remove(dict, lhs);
                        if (dict2.Count > 0)
                        {
                            newBindingSet.set.Add(dict2);
                        }
                    }
                    if (missing != null)
                    {
                        newBindingSet.set.AddRange(missing.set);
                    }
                }
                return(newBindingSet);
            }
        public void CreateBinding(GameObject obj)
        {
            _viewGameObject = obj;
            _viewCanvas     = _viewGameObject.GetComponent <Canvas>();

            var view = obj.GetComponent <GroupTechStatView>();

            if (view != null)
            {
                _view = view;
                Reset();                        //回滚初始值
                view.BindingContext().DataContext = this;
                return;
            }

            view  = obj.AddComponent <GroupTechStatView>();
            _view = view;
            view.FillField();
            view.BindingContext().DataContext = this;

            BindingSet <GroupTechStatView, GroupTechStatViewModel> bindingSet =
                view.CreateBindingSet <GroupTechStatView, GroupTechStatViewModel>();

            view.oriShow = _show = view.Show.activeSelf;
            bindingSet.Bind(view.Show).For(v => v.activeSelf).To(vm => vm.Show).OneWay();
            view.oriRoomInfoText = _roomInfoText = view.RoomInfoText.text;
            bindingSet.Bind(view.RoomInfoText).For(v => v.text).To(vm => vm.RoomInfoText).OneWay();
            view.oriPlayerCountText = _playerCountText = view.PlayerCountText.text;
            bindingSet.Bind(view.PlayerCountText).For(v => v.text).To(vm => vm.PlayerCountText).OneWay();
            bindingSet.Build();

            SpriteReset();
        }
Example #18
0
        protected override void Start()
        {
            VariableViewModel viewModel = new VariableViewModel()
            {
                Username = "******",
                Email    = "*****@*****.**",
                Remember = true
            };

            viewModel.Color  = this.variables.Get <Color>("color");
            viewModel.Vector = this.variables.Get <Vector3>("vector");

            IBindingContext bindingContext = this.BindingContext();

            bindingContext.DataContext = viewModel;

            /* databinding */
            BindingSet <VariableExample, VariableViewModel> bindingSet = this.CreateBindingSet <VariableExample, VariableViewModel>();

            bindingSet.Bind(this.variables.Get <InputField>("username")).For(v => v.text, v => v.onEndEdit).To(vm => vm.Username).TwoWay();
            bindingSet.Bind(this.variables.Get <InputField>("email")).For(v => v.text, v => v.onEndEdit).To(vm => vm.Email).TwoWay();
            bindingSet.Bind(this.variables.Get <Toggle>("remember")).For(v => v.isOn, v => v.onValueChanged).To(vm => vm.Remember).TwoWay();
            bindingSet.Bind(this.variables.Get <Button>("submit")).For(v => v.onClick).To(vm => vm.OnSubmit());
            bindingSet.Build();
        }
        public BindingModeView()
        {
            InitializeComponent();

            using (var set = new BindingSet<BindingModeViewModel>())
            {
                set.Bind(oneTimeTb)
                    .To(() => (vm, ctx) => vm.Text)
                    .OneTime();
                set.Bind(oneWayTb)
                    .To(() => (vm, ctx) => vm.Text)
                    .OneWay();
                set.Bind(oneWayDelayTb)
                    .To(() => (vm, ctx) => vm.Text)
                    .OneWay()
                    .WithDelay(1000, true);
                set.Bind(oneWaySrcTb)
                    .To(() => (vm, ctx) => vm.Text)
                    .OneWayToSource();
                set.Bind(twoWayTb)
                    .To(() => (vm, ctx) => vm.Text)
                    .TwoWay();
                set.Bind(twoWayDelayTb)
                    .To(() => (vm, ctx) => vm.Text)
                    .TwoWay()
                    .WithDelay(1000);
            }
        }
Example #20
0
        public override void Bind(BindingSet <HomeViewModel> bindingSet)
        {
            base.Bind(bindingSet);

            bindingSet.Bind(VacationsAdapter)
            .For(v => v.ItemClickedBinding())
            .To(vm => vm.VacationSelectedCommand);

            bindingSet.Bind(ViewHolder.LogoutButton)
            .For(v => v.ClickBinding())
            .To(vm => vm.LogoutCommand);

            bindingSet.Bind(ViewHolder.AddVacationButton)
            .For(v => v.ClickBinding())
            .To(vm => vm.VacationSelectedCommand);

            bindingSet.Bind(ViewHolder.SwipeRefresh)
            .For(v => v.RefreshingBinding())
            .To(vm => vm.Loading)
            .TwoWay();

            bindingSet.Bind(ViewHolder.SwipeRefresh)
            .For(v => v.RefreshBinding())
            .To(vm => vm.RefreshCommand);
        }
        protected override void Initialize(UITableViewCell template,
                                           BindingSet <UITableViewCell, TableItemModel> bindingSet)
        {
            template.SetEditingStyle(UITableViewCellEditingStyle.Delete);
            template.Accessory = UITableViewCellAccessory.DetailDisclosureButton;
            template.DetailTextLabel.AdjustsFontSizeToFitWidth = true;

            bindingSet.Bind(AttachedMembers.UITableViewCell.AccessoryButtonTappedEvent)
            .To(() => (m, ctx) => ctx.Relative <UIViewController>().DataContext <TableViewModel>().ItemClickCommand)
            .OneTime()
            .WithCommandParameter(() => (m, ctx) => m)
            .ToggleEnabledState(false);
            bindingSet.Bind(AttachedMembers.UITableViewCell.DeleteClickEvent)
            .To(() => (m, ctx) => ctx.Relative <UIViewController>().DataContext <TableViewModel>().RemoveCommand)
            .OneTime()
            .WithCommandParameter(() => (m, ctx) => m)
            .ToggleEnabledState(false);

            bindingSet.Bind(() => viewCell => viewCell.Selected).To(() => (m, ctx) => m.IsSelected).TwoWay();
            bindingSet.Bind(AttachedMembers.UITableViewCell.TitleForDeleteConfirmation)
            .To(() => (m, ctx) => "Delete " + m.Name);
            bindingSet.Bind(template.TextLabel).To(() => (m, ctx) => m.Name);
            bindingSet.Bind(template.DetailTextLabel)
            .To(() => (m, ctx) => $"Selected: {m.IsSelected}");
        }
Example #22
0
        protected override void OnCreate(IBundle bundle)
        {
            this.viewLocator     = Context.GetApplicationContext().GetService <IUIViewLocator>();
            this.command         = new SimpleCommand(OpenLoginWindow);
            this.viewModel       = new StartupViewModel();
            this.viewModel.Click = this.command;
            //this.subscription = this.viewModel.Messenger.Subscribe ();

            //		this.SetDataContext (viewModel);

            /* databinding, Bound to the ViewModel. */
            BindingSet <StartupWindow, StartupViewModel> bindingSet = this.CreateBindingSet(viewModel);

            bindingSet.Bind(this.progressBarSlider).For("value", "onValueChanged").To("ProgressBar.Progress").TwoWay();
            //			bindingSet.Bind (this.progressBarSlider).For (v => v.value, v => v.onValueChanged).To (vm => vm.ProgressBar.Progress).TwoWay ();

            /* //by the way,You can expand your attributes.
             *  ProxyFactory proxyFactory = ProxyFactory.Default;
             *  PropertyInfo info = typeof(GameObject).GetProperty ("activeSelf");
             *  proxyFactory.Register (new ProxyPropertyInfo<GameObject, bool> (info, go => go.activeSelf, (go, value) => go.SetActive (value)));
             */

            bindingSet.Bind(this.progressBarSlider.gameObject).For(v => v.activeSelf).To(vm => vm.ProgressBar.Enable).OneWay();
            bindingSet.Bind(this.progressBarText).For(v => v.text).ToExpression(vm => string.Format("{0}%", Mathf.FloorToInt(vm.ProgressBar.Progress * 100f))).OneWay();/* expression binding,support only OneWay mode. */
            bindingSet.Bind(this.tipText).For(v => v.text).To(vm => vm.ProgressBar.Tip).OneWay();

            //bindingSet.Bind (this.button).For (v => v.onClick).To (vm=>vm.OnClick()).OneWay (); //Method binding,only bound to the onClick event.
            bindingSet.Bind(this.button).For(v => v.onClick).To(vm => vm.Click).OneWay();//Command binding,bound to the onClick event and interactable property.
            bindingSet.Build();

            this.Unzip();
        }
        public ChildView()
        {
            InitializeComponent();

            using (var set = new BindingSet <ChildViewModel>())
            {
                set.Bind(this, () => v => v.Text)
                .To(() => (vm, ctx) => vm.DisplayName);
                set.Bind(textBoxParameter, () => v => v.Text)
                .To(() => (vm, ctx) => vm.Parameter)
                .TwoWay()
                .Validate();
                set.Bind(buttonUpdateParameter)
                .To(() => (vm, ctx) => vm.ApplyCommand);
                set.Bind(buttonClose)
                .To(() => (vm, ctx) => vm.CloseCommand);

                set.Bind(progressBarIsBusy, () => v => v.Visible)
                .To(() => (vm, ctx) => vm.IsBusy);
                set.Bind(labelBusyMessage, () => v => v.Visible)
                .To(() => (vm, ctx) => vm.IsBusy);
                set.Bind(labelBusyMessage, () => v => v.Text)
                .To(() => (vm, ctx) => vm.BusyMessage);
            }
        }
        public override void Bind(BindingSet <VacationCellViewModel> bindingSet)
        {
            base.Bind(bindingSet);

            bindingSet.Bind(VacationType)
            .For(v => v.Text)
            .To(vm => vm.Type)
            .WithConvertion <VacationTypeValueConverter>();

            bindingSet.Bind(VacationStatus)
            .For(v => v.Text)
            .To(vm => vm.Status)
            .WithConvertion <VacationStatusValueConverter>();

            bindingSet.Bind(VacationDuration)
            .For(v => v.Text)
            .To(vm => vm.Duration)
            .WithConvertion <DurationValueConverter>();

            bindingSet.Bind(VacationImage)
            .For(v => v.SetImageResourceBinding())
            .To(vm => vm.Type)
            .WithConvertion <ImageValueConverter>();

            bindingSet.Bind(SeparatorView)
            .For(v => v.Visibility)
            .To(vm => vm.SeparatorVisible)
            .WithConvertion <SeparatorVisibilityValueConverter>();
        }
        public override void Bind(BindingSet <VacationStatusModel> bindingSet)
        {
            base.Bind(bindingSet);

            bindingSet.Bind(_radioButton).For(v => v.CheckedAndCheckedChangeBinding()).To(vm => vm.IsSelected);
            bindingSet.Bind(_radioButton).For(v => v.TextBinding()).To(vm => vm.Title);
        }
 protected override void Initialize(
     UITableViewCell template, BindingSet <UITableViewCell, Person> bindingSet)
 {
     template.SetEditingStyle(UITableViewCellEditingStyle.None);
     template.TextLabel.AdjustsFontSizeToFitWidth = true;
     bindingSet.Bind(template.TextLabel).To(() => (m, ctx) => m.Name);
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;
            CollectionView.BackgroundColor = UIColor.White;

            using (var set = new BindingSet<TableViewModel>())
            {
                NavigationItem.RightBarButtonItems = new[]
                {
                    new UIBarButtonItem {Title = "Add"}.SetBindings(set,
                        (bindingSet, item) => bindingSet.Bind(item).To(() => (m, ctx) => m.AddCommand)),
                    new UIBarButtonItem {Title = "Remove"}.SetBindings(set,
                        (bindingSet, item) => bindingSet.Bind(item).To(() => (m, ctx) => m.RemoveCommand))
                };

                CollectionView.SetBindingMemberValue(AttachedMembers.UICollectionView.ItemTemplateSelector,
                    CollectionViewCellTemplateSelector.Instance);
                set.Bind(CollectionView, AttachedMemberConstants.ItemsSource)
                    .To(() => (m, ctx) => m.GridViewModel.ItemsSource);
                set.Bind(CollectionView, AttachedMemberConstants.SelectedItem)
                    .To(() => (m, ctx) => m.GridViewModel.SelectedItem)
                    .TwoWay();
                set.Bind(this, () => controller => controller.Title)
                    .To(() => (m, ctx) => m.GridViewModel.SelectedItem.Name)
                    .WithFallback("Nothing selected");
            }
        }
Example #28
0
        private void PrepareTextView()
        {
            var textview = FindViewById <TextView>(Resource.Id.firstview_textview);

            BindingSet.Bind(textview).To(vm => vm.Hello);
            BindingSet.Apply();
        }
Example #29
0
        /// <summary>
        /// Advances the right input stream cursor, storing the result in a local variable for
        /// consumption.
        /// </summary>
        /// <returns>
        /// <c>true</c> if the cursor was successfully advanced; otherwise, <c>false</c>.
        /// </returns>
        private bool AdvanceRight()
        {
            if (m_cursorRightMovePrev)
            {
                //
                // BerkeleyDB's support for Cursor.MovePrev() is broken and doesn't work correctly
                // on edge cases, so we have this hacky workaround

                m_cursorRightMovePrev = false;
                return(true);
            }
#if DEBUG
            m_planOperator.StartIOWork();
#endif
            //
            // try to advance the cursor, and store the result in a local variable. if the cursor
            // cannot be advanced then we are done here

            if (m_cursorRight.MoveNext())
            {
#if DEBUG
                m_planOperator.StopIOWork();
#endif
                m_rightNext = Encoding.DbDecodeBindingSet(m_cursorRight.Current.Value.Data);
                return(true);
            }
            else
            {
#if DEBUG
                m_planOperator.StopIOWork();
#endif
                return(false);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            using (var set = new BindingSet <ResultViewModel>())
            {
                var textLb = new UITextField(new CGRect(0, 70, View.Frame.Width, 30))
                {
                    TextAlignment = UITextAlignment.Center
                };
                set.Bind(textLb).To(nameof(ResultViewModel.Result)).TwoWay();
                View.AddSubview(textLb);

                UIButton button = UIButton.FromType(UIButtonType.System);
                button.Frame = new CGRect(0, 100, View.Frame.Width, 30);
                button.SetTitle("Show Opened View Models", UIControlState.Normal);
                set.Bind(button).To(() => (vm, ctx) => vm.ShowOpenedViewModelsCommand);
                View.AddSubview(button);

                button       = UIButton.FromType(UIButtonType.System);
                button.Frame = new CGRect(0, 130, View.Frame.Width, 30);
                button.SetTitle("Close", UIControlState.Normal);
                set.Bind(button).To(() => (vm, ctx) => vm.CloseCommand);
                View.AddSubview(button);
            }
        }
Example #31
0
    protected override void OnCreate(IBundle bundle)
    {
        //RewardViewModel rewardViewModel = new RewardViewModel();

        //this.SetDataContext(rewardViewModel);

        this.toastInteractionAction = new ToastInteractionAction(this);

        BindingSet <RewardWindow, RewardViewModel> bindingSet = this.CreateBindingSet <RewardWindow, RewardViewModel>();

        bindingSet.Bind().For(v => v.Coupons).To(vm => vm.Coupons).OneWay();

        bindingSet.Bind(this.image).For(v => v.sprite).To(vm => vm.Icon).WithConversion("merchandiseConverter").OneWay();

        bindingSet.Bind(this.phoneNumber).For(v => v.text, v => v.onEndEdit).To(vm => vm.PhoneNumber).TwoWay();

        bindingSet.Bind().For(v => v.OnOpenAlert).To(vm => vm.AlertDialogRequest);

        bindingSet.Bind(this.receiveReward).For(v => v.onClick).To(vm => vm.ReceiveReward).OneWay();

        bindingSet.Bind(this.terminate).For(v => v.onClick).To(vm => vm.Terminate).OneWay();

        bindingSet.Bind().For(v => v.OnInteractionFinished).To(vm => vm.InteractionFinished);

        bindingSet.Bind(this.countDown).For(v => v.text).ToExpression(vm => string.Format("{0}", vm.CountDown)).TwoWay();

        bindingSet.Bind().For(v => v.toastInteractionAction).To(vm => vm.ToastRequest);

        bindingSet.Build();
    }
Example #32
0
        public ProductWorkspaceView()
        {
            InitializeComponent();
            using (var set = new BindingSet <ProductWorkspaceView, ProductWorkspaceViewModel>(this))
            {
                set.Bind(dataGridView1, AttachedMembers.Object.ItemsSource)
                .To(() => (vm, ctx) => vm.GridViewModel.ItemsSource);
                set.Bind(dataGridView1, AttachedMembers.DataGridView.SelectedItem)
                .To(() => (vm, ctx) => vm.GridViewModel.SelectedItem)
                .TwoWay();
                set.Bind(toolStripTextBox1)
                .To(() => (vm, ctx) => vm.FilterText)
                .TwoWay();

                set.Bind(saveToolStripButton)
                .To(() => (vm, ctx) => vm.SaveChangesCommand);
                set.Bind(addToolStripButton)
                .To(() => (vm, ctx) => vm.AddProductCommand);
                set.Bind(editToolStripButton)
                .To(() => (vm, ctx) => vm.EditProductCommand);
                set.Bind(deleteToolStripButton)
                .To(() => (vm, ctx) => vm.RemoveProductCommand);
                set.Bind(closeToolStripButton)
                .To(() => (vm, ctx) => vm.CloseCommand);
            }
            dataGridView1.AutoGenerateColumns = false;
        }
        public DataAnnotationView()
        {
            InitializeComponent();
            using (var set = new BindingSet<DataAnnotationViewModel>())
            {
                set.Bind(nameTextBox)
                   .To(() => (vm, ctx) => vm.NameInVm)
                   .TwoWay()
                   .Validate();
                set.Bind(nameErrorLabel)
                   .To(() => (vm, ctx) => ctx.GetErrors(vm.NameInVm).FirstOrDefault());

                set.Bind(descriptionTextBox)
                   .To(() => (vm, ctx) => vm.Description)
                   .TwoWay()
                   .Validate();
                set.Bind(descErrorLabel)
                   .To(() => (vm, ctx) => ctx.GetErrors(vm.Description).FirstOrDefault());

                set.Bind(customErrorTextBox)
                   .To(() => (vm, ctx) => vm.CustomError)
                   .TwoWay();
                set.Bind(checkBox1)
                   .To(() => (vm, ctx) => vm.DisableDescriptionValidation)
                   .TwoWay();
                set.Bind(notValidLabel, () => t => t.Visible)
                   .To(() => (vm, ctx) => !vm.IsValid);
                set.Bind(validLabel, () => t => t.Visible)
                   .To(() => (vm, ctx) => vm.IsValid);
                set.Bind(summaryLabel)
                   .To(() => (vm, ctx) => string.Join(Environment.NewLine, ctx.GetErrors()));
            }
        }
Example #34
0
 protected override void Initialize(StringElement template,
                                    BindingSet <StringElement, Tuple <string, Type> > bindingSet)
 {
     bindingSet.Bind(element => element.Caption).To(tuple => tuple.Item1);
     bindingSet.Bind(AttachedMemberConstants.CommandParameter).To(tuple => tuple.Item2);
     bindingSet.BindFromExpression("Tapped $Relative(UIViewController).DataContext.ShowCommand");
 }
Example #35
0
        void Start()
        {
            viewModel = new ListViewViewModel();
            for (int i = 0; i < 3; i++)
            {
                viewModel.AddItem();
            }
            viewModel.Items[0].IsSelected = true;

            IBindingContext bindingContext = this.BindingContext();

            bindingContext.DataContext = viewModel;

            BindingSet <ListViewDatabindingExample, ListViewViewModel> bindingSet = this.CreateBindingSet <ListViewDatabindingExample, ListViewViewModel>();

            bindingSet.Bind(this.listView).For(v => v.Items).To(vm => vm.Items).OneWay();
            bindingSet.Bind(this.listView).For(v => v.OnSelectChanged).To <int>(vm => vm.Select).OneWay();

            bindingSet.Bind(this.addButton).For(v => v.onClick).To(vm => vm.AddItem);
            bindingSet.Bind(this.removeButton).For(v => v.onClick).To(vm => vm.RemoveItem);
            bindingSet.Bind(this.clearButton).For(v => v.onClick).To(vm => vm.ClearItem);
            bindingSet.Bind(this.changeIconButton).For(v => v.onClick).To(vm => vm.ChangeItemIcon);

            bindingSet.Build();
        }
Example #36
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            using (var set = new BindingSet <NavigationViewModelBase>())
            {
                var textLb = new UILabel(new CGRect(0, 70, View.Frame.Width, 30))
                {
                    TextAlignment = UITextAlignment.Center
                };
                set.Bind(textLb).To("Text");
                View.AddSubview(textLb);

                var button = UIButton.FromType(UIButtonType.System);
                button.Frame = new CGRect(0, 100, View.Frame.Width, 30);
                button.SetTitle("Close", UIControlState.Normal);
                set.Bind(button).To(() => (vm, ctx) => vm.CloseCommand);
                View.AddSubview(button);

                button       = UIButton.FromType(UIButtonType.System);
                button.Frame = new CGRect(0, 130, View.Frame.Width, 30);
                button.SetTitle("Show Opened View Models", UIControlState.Normal);
                set.Bind(button).To(() => (vm, ctx) => vm.ShowOpenedViewModelsCommand);
                View.AddSubview(button);

                button       = UIButton.FromType(UIButtonType.System);
                button.Frame = new CGRect(0, 160, View.Frame.Width, 30);
                button.SetTitle("Next Page", UIControlState.Normal);
                set.Bind(button).To <PageViewModel>(() => (vm, ctx) => vm.ToNextPageCommand);
                set.Bind(button, AttachedMembers.UIView.Visible).To(() => (vm, ctx) => vm is PageViewModel);
                View.AddSubview(button);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title = "Main view";
            View.BackgroundColor = UIColor.White;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Navigation", UIBarButtonItemStyle.Plain,
                (sender, args) =>
                {
                    var actionSheet = new UIActionSheet("Navigation");

                    actionSheet.AddButtonWithBinding("First view model modal", "Click ShowFirstWindowCommand");
                    actionSheet.AddButtonWithBinding("First view model page", "Click ShowFirstPageCommand");
                    actionSheet.AddButtonWithBinding("First view model tab", "Click ShowFirstTabCommand");

                    actionSheet.AddButtonWithBinding("Second view model modal", "Click ShowSecondWindowCommand");
                    actionSheet.AddButtonWithBinding("Second view model page", "Click ShowSecondPageCommand");
                    actionSheet.AddButtonWithBinding("Second view model tab", "Click ShowSecondTabCommand");

                    actionSheet.AddButtonWithBinding("Navigation (Clear back stack)", "Click ShowBackStackPageCommand");

                    actionSheet.CancelButtonIndex = actionSheet.AddButton("Cancel");
                    actionSheet.ShowEx(sender, (sheet, o) => sheet.ShowFrom((UIBarButtonItem)o, true));
                });


            using (var bindingSet = new BindingSet<MainViewModel>())
            {
                //TabBar
                bindingSet.Bind(this, AttachedMemberConstants.ItemsSource).To(() => model => model.ItemsSource);
                bindingSet.Bind(this, AttachedMemberConstants.SelectedItem).To(() => model => model.SelectedItem).TwoWay();
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            TableView.AllowsSelection = true;
            TableView.SetCellStyle(UITableViewCellStyle.Subtitle);
            using (var set = new BindingSet<UITableView, TableViewModel>(TableView))
            {
                var editItem = new UIBarButtonItem { Title = "Edit" };
                editItem.Clicked += (sender, args) =>
                {
                    TableView.Editing = !TableView.Editing;
                    NavigationItem.RightBarButtonItem.Title = TableView.Editing ? "Done" : "Edit";
                };
                var addItem = new UIBarButtonItem { Title = "Add" };
                set.Bind(addItem).To(() => (vm, ctx) => vm.AddCommand);
                NavigationItem.RightBarButtonItems = new[] { editItem, addItem };

                var searchBar = new UISearchBar(new RectangleF(0, 0, 320, 44)) { Placeholder = "Filter..." };
                set.Bind(searchBar).To(() => (vm, ctx) => vm.FilterText).TwoWay();
                TableView.TableHeaderView = searchBar;

                set.Bind(AttachedMemberConstants.ItemsSource)
                    .To(() => (vm, ctx) => vm.GridViewModel.ItemsSource);
                set.Bind(AttachedMemberConstants.SelectedItem)
                    .To(() => (vm, ctx) => vm.GridViewModel.SelectedItem)
                    .TwoWay();
                set.Bind(this, () => controller => controller.Title)
                    .To(() => (vm, ctx) => vm.GridViewModel.SelectedItem.Name)
                    .WithFallback("Nothing selected");
                TableView.SetBindingMemberValue(AttachedMembers.UITableView.ItemTemplateSelector, TableCellTemplateSelector.Instance);
            }
        }
Example #39
0
        void ViewBind(CommonLocateView view)
        {
            BindingSet <CommonLocateView, CommonLocateViewModel> bindingSet =
                view.CreateBindingSet <CommonLocateView, CommonLocateViewModel>();

            bindingSet.Build();
        }
 public ContentForm()
 {
     InitializeComponent();
     using (var set = new BindingSet<ContentViewModel>())
     {
         set.Bind(this, AttachedMemberConstants.Content).To(() => (vm, ctx) => vm.ViewModel);
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;
            Title = "Main info";

            var scrollView = new UIScrollView(new CGRect(0, 0, View.Frame.Width, View.Frame.Height))
            {
                ScrollEnabled = true,
                ContentSize = new CGSize(View.Bounds.Size.Width, View.Bounds.Size.Height),
                AutoresizingMask = UIViewAutoresizing.FlexibleDimensions
            };
            View.AddSubview(scrollView);

            using (var set = new BindingSet<OrderEditorViewModel>())
            {
                UIFont font = UIFont.SystemFontOfSize(12);

                var label = new UILabel(new CGRect(20, 0, View.Frame.Width - 40, 25))
                {
                    Text = "Name",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font = font
                };
                scrollView.AddSubview(label);

                var textField = new UITextField(new CGRect(20, 25, View.Frame.Width - 40, 30))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    BorderStyle = UITextBorderStyle.RoundedRect,
                };
                set.Bind(textField)
                    .To(() => (vm, ctx) => vm.Name)
                    .TwoWay()
                    .Validate();
                scrollView.AddSubview(textField);


                label = new UILabel(new CGRect(20, 55, View.Frame.Width - 40, 25))
                {
                    Text = "Number",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font = font
                };
                scrollView.AddSubview(label);

                textField = new UITextField(new CGRect(20, 80, View.Frame.Width - 40, 30))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    BorderStyle = UITextBorderStyle.RoundedRect
                };
                set.Bind(textField)
                    .To(() => (vm, ctx) => vm.Number)
                    .TwoWay()
                    .Validate();
                scrollView.AddSubview(textField);
            }
        }
 public ContentFormContentManager()
 {
     InitializeComponent();
     using (var set = new BindingSet<ContentViewModel>())
     {
         set.Bind(this, AttachedMemberConstants.Content).To(() => vm => vm.ViewModel);
         this.SetBindingMemberValue(AttachedMembers.Control.ContentViewManager, ContentViewManager.Instance);
     }
 }
 public ItemView()
 {
     InitializeComponent();
     AutoSize = true;
     using (var set = new BindingSet<ItemViewModel>())
     {
         set.Bind(label).To(() => vm => vm.Name + " " + vm.Id);
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            using (var set = new BindingSet<ProductWorkspaceViewModel>())
            {
                set.Bind(this, () => controller => controller.Title).To(() => (vm, ctx) => vm.DisplayName);

                var addItem = new UIBarButtonItem("Add", UIBarButtonItemStyle.Plain, null);
                set.Bind(addItem).To(() => (vm, ctx) => vm.AddProductCommand);

                var saveItem = new UIBarButtonItem("Save", UIBarButtonItemStyle.Done, null);
                set.Bind(saveItem).To(() => (vm, ctx) => vm.SaveChangesCommand);
                NavigationItem.RightBarButtonItems = new[] { addItem, saveItem };

                var searchBar = new UISearchBar(new CGRect(0, 0, 320, 44)) { Placeholder = "Filter..." };
                set.Bind(searchBar).To(() => (vm, ctx) => vm.FilterText).TwoWay();
                TableView.TableHeaderView = searchBar;

                set.Bind(View, AttachedMembersEx.UIView.IsBusy).To(() => (vm, ctx) => vm.IsBusy);
                set.Bind(View, AttachedMembersEx.UIView.BusyMessage).To(() => (vm, ctx) => vm.BusyMessage);

                set.Bind(TableView, AttachedMembers.UIView.ItemsSource).To(() => (vm, ctx) => vm.GridViewModel.ItemsSource);
                set.Bind(TableView, AttachedMembers.UITableView.SelectedItem)
                    .To(() => (vm, ctx) => vm.GridViewModel.SelectedItem)
                    .TwoWay();
            }

            TableView.SetCellStyle(UITableViewCellStyle.Subtitle);
            TableView.SetCellBind(cell =>
            {
                cell.SetEditingStyle(UITableViewCellEditingStyle.Delete);
                cell.Accessory = UITableViewCellAccessory.DetailDisclosureButton;
                cell.DetailTextLabel.AdjustsFontSizeToFitWidth = true;
                using (var set = new BindingSet<ProductModel>())
                {
                    set.Bind(cell, AttachedMembers.UITableViewCell.AccessoryButtonTappedEvent)
                        .To(() => (m, ctx) => ctx.Relative<UIViewController>().DataContext<ProductWorkspaceViewModel>().EditProductCommand)
                        .OneTime()
                        .WithCommandParameter(() => (m, ctx) => m)
                        .ToggleEnabledState(false);
                    set.Bind(cell, AttachedMembers.UITableViewCell.DeleteClickEvent)
                        .To(() => (m, ctx) => ctx.Relative<UIViewController>().DataContext<ProductWorkspaceViewModel>().RemoveProductCommand)
                        .OneTime()
                        .WithCommandParameter(() => (m, ctx) => m)
                        .ToggleEnabledState(false);
                    set.Bind(cell.TextLabel)
                       .To(() => (m, ctx) => m.Name);
                    set.Bind(cell.DetailTextLabel)
                       .To(() => (m, ctx) => m.Description);
                    set.Bind(cell, AttachedMembers.UITableViewCell.TitleForDeleteConfirmation)
                        .To(() => (m, ctx) => string.Format("Delete {0}", m.Name));
                }
            });
        }
 public MainForm()
 {
     InitializeComponent();
     using (var set = new BindingSet<MainViewModel>())
     {
         set.Bind(tableLayoutPanel1, AttachedMemberConstants.ItemsSource).To(() => (vm, ctx) => vm.Items);
         tableLayoutPanel1.SetBindingMemberValue(AttachedMembers.Object.ItemTemplateSelector,
             ButtonItemTemplate.Instance);
     }
 }
 public MainView()
 {
     InitializeComponent();
     using (var set = new BindingSet<MainViewModel>())
     {
         set.Bind(dataAnnotButton)
            .To(() => (vm, ctx) => vm.ShowAnnotationCommand);
         set.Bind(validatorButton)
            .To(() => (vm, ctx) => vm.ShowUserEditorCommand);
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            TableView.AllowsSelection = true;
            TableView.AllowsMultipleSelection = false;
            TableView.SetCellStyle(UITableViewCellStyle.Subtitle);
            using (var set = new BindingSet<UITableView, CollectionBindingViewModel>(TableView))
            {
                var editItem = new UIBarButtonItem { Title = "Edit" };
                editItem.Clicked += (sender, args) =>
                {
                    TableView.Editing = !TableView.Editing;
                    NavigationItem.RightBarButtonItem.Title = TableView.Editing ? "Done" : "Edit";
                };
                var addItem = new UIBarButtonItem { Title = "Add" };
                set.Bind(addItem).To(() => (vm, ctx) => vm.AddCommand);
                NavigationItem.RightBarButtonItems = new[] { editItem, addItem };

                var searchBar = new UISearchBar(new CGRect(0, 0, 320, 44)) { Placeholder = "Filter..." };
                set.Bind(searchBar).To(() => (vm, ctx) => vm.FilterText).TwoWay();
                TableView.TableHeaderView = searchBar;

                set.Bind(AttachedMemberConstants.ItemsSource)
                    .To(() => (vm, ctx) => vm.GridViewModel.ItemsSource);
                set.Bind(AttachedMemberConstants.SelectedItem)
                    .To(() => (vm, ctx) => vm.GridViewModel.SelectedItem)
                    .TwoWay();
                set.Bind(this, () => controller => controller.Title)
                    .To(() => (vm, ctx) => vm.GridViewModel.SelectedItem.Name)
                    .WithFallback("Nothing selected");
            }

            TableView.SetCellBind(cell =>
            {
                cell.SetEditingStyle(UITableViewCellEditingStyle.Delete);
                cell.Accessory = UITableViewCellAccessory.None;
                cell.DetailTextLabel.AdjustsFontSizeToFitWidth = true;

                using (var set = new BindingSet<CollectionItemModel>())
                {
                    set.Bind(cell, AttachedMembers.UITableViewCell.DeleteClickEvent)
                        .To(() => (vm, ctx) => ctx.Relative<UIViewController>().DataContext<CollectionBindingViewModel>().RemoveCommand)
                        .WithCommandParameter(() => (m, ctx) => ctx.Self().DataContext())
                        .ToggleEnabledState(false);
                    set.Bind(cell, AttachedMembers.UITableViewCell.TitleForDeleteConfirmation)
                        .To(() => (m, ctx) => string.Format("Delete {0} {1}", m.Name, m.Id));
                    set.Bind(cell.TextLabel).To(() => (m, ctx) => m.Name);
                    set.Bind(cell.DetailTextLabel)
                        .To(() => (m, ctx) => "Id " + m.Id);
                }
            });
        }
        public AttachedMemberView()
        {
            InitializeComponent();

            using (var set = new BindingSet<AttachedMemberViewModel>())
            {
                set.Bind(textBox).To(() => model => model.Text).TwoWay();
                set.Bind(autoPropLabel, "TextExt").To(() => vm => vm.Text);
                set.Bind(customPropLabel, "FormattedText").To(() => vm => vm.Text);
            }
        }
 private static RootElement CreateRootElement()
 {
     using (var bindingSet = new BindingSet<MainViewModel>())
     {
         var root = new RootElement("Main view");
         var section = new Section("Examples");
         root.Add(section);
         bindingSet.Bind(section, AttachedMemberConstants.ItemsSource).To(() => (vm, ctx) => vm.Items);
         section.SetBindingMemberValue(AttachedMembers.Element.ItemTemplateSelector, ButtonItemTemplateSelector.Instance);
         return root;
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            using (var set = new BindingSet<ContentViewModel>())
            {
                set.Bind(View, AttachedMemberConstants.Content).To(() => model => model.ViewModel);
                View.SetBindingMemberValue(AttachedMembers.UIView.ContentTemplateSelector, LabelItemTemplateSelector.Instance);
                View.SetBindingMemberValue(AttachedMembers.UIView.ContentViewManager, ContentViewManager.Instance);
            }
        }
        public CollectionViewManagerForm()
        {
            InitializeComponent();

            using (var set = new BindingSet<TabViewModel>())
            {
                set.Bind(addToolStripButton).To(() => model => model.AddCommand);
                set.Bind(removeToolStripButton).To(() => model => model.RemoveCommand);
                set.Bind(tableLayoutPanel, AttachedMemberConstants.ItemsSource).To(() => model => model.ItemsSource);
                tableLayoutPanel.SetBindingMemberValue(AttachedMembers.Object.CollectionViewManager, TableLayoutCollectionViewManager.Instance);
            }
        }
 public TabForm()
 {
     InitializeComponent();
     using (var set = new BindingSet<TabViewModel>())
     {
         set.Bind(addToolStripButton).To(() => vm => vm.AddCommand);
         set.Bind(insertToolStripButton).To(() => vm => vm.InsertCommand);
         set.Bind(removeToolStripButton).To(() => vm => vm.RemoveCommand);
         set.Bind(tabControl, AttachedMemberConstants.ItemsSource).To(() => vm => vm.ItemsSource);
         set.Bind(tabControl, AttachedMemberConstants.SelectedItem).To(() => vm => vm.SelectedItem).TwoWay();
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            using (var set = new BindingSet<SecondViewModel>())
            {
                UIButton button = UIButton.FromType(UIButtonType.System);
                button.Frame = new CGRect(0, 70, View.Frame.Width, 30);
                button.SetTitle("Close from view model (First view)", UIControlState.Normal);
                set.Bind(button).To(() => model => model.CloseCommand);
                View.AddSubview(button);
            }
        }
        public TabFormItemTemplate()
        {
            InitializeComponent();

            using (var set = new BindingSet<TabViewModel>())
            {
                set.Bind(addToolStripButton).To(() => (vm, ctx) => vm.AddCommand);
                set.Bind(insertToolStripButton).To(() => (vm, ctx) => vm.InsertCommand);
                set.Bind(removeToolStripButton).To(() => (vm, ctx) => vm.RemoveCommand);
                set.Bind(tabControl, AttachedMemberConstants.ItemsSource).To(() => (vm, ctx) => vm.ItemsSource);
                set.Bind(tabControl, AttachedMemberConstants.SelectedItem).To(() => (vm, ctx) => vm.SelectedItem).TwoWay();
                tabControl.SetBindingMemberValue(AttachedMembers.Object.ItemTemplateSelector, TabItemTemplate.Instance);
            }
        }
        public MainForm()
        {
            InitializeComponent();
            using (var set = new BindingSet<MainViewModel>())
            {
                set.Bind(firstViewModelWindowToolStripMenuItem).To(() => m => m.ShowFirstWindowCommand);
                set.Bind(secondViewModelWindowToolStripMenuItem).To(() => m => m.ShowSecondWindowCommand);
                set.Bind(firstViewModelTabToolStripMenuItem).To(() => m => m.ShowFirstTabCommand);
                set.Bind(secondViewModelTabToolStripMenuItem).To(() => m => m.ShowSecondTabCommand);

                set.Bind(tabControl1, AttachedMembers.Object.ItemsSource).To(() => m => m.ItemsSource);
                set.Bind(tabControl1, AttachedMembers.TabControl.SelectedItem).To(() => m => m.SelectedItem).TwoWay();
            }
        }
        public MainForm()
        {
            InitializeComponent();

            using (var set = new BindingSet<MainViewModel>())
            {
                tableLayoutPanel1.SetBindingMemberValue(AttachedMembers.Object.ItemTemplateSelector,
                    ButtonItemTemplate.Instance);
                set.Bind(tableLayoutPanel1, AttachedMemberConstants.ItemsSource)
                   .To(() => (vm, ctx) => vm.Items);
                set.Bind(toolStripStatusLabel, () => t => t.Text)
                   .To(() => (vm, ctx) => vm.ResourceUsageInfo);
            }
        }
        public BindingResourcesView()
        {
            InitializeComponent();

            using (var set = new BindingSet<BindingResourcesViewModel>())
            {
                set.Bind(objLabel)
                    .To(() => (vm, ctx) => ctx.Resource<object>("obj"));
                set.Bind(methodLabel)
                    .To(() => (vm, ctx) => ctx.ResourceMethod<object>("Method"));
                set.BindFromExpression(typeLabel, "Text $CustomType.StaticMethod()");
                set.Bind(updateResBtn)
                    .To(() => (vm, ctx) => vm.UpdateResourceCommand);
            }
        }
        public DynamicObjectView()
        {
            InitializeComponent();

            using (var set = new BindingSet<DynamicObjectViewModel>())
            {
                set.Bind(dynamicTb)
                    .To(() => vm => vm.DynamicModel.Member<object>("DynamicProperty"))
                    .TwoWay();
                set.Bind(dynamicLabel)
                    .To(() => vm => vm.DynamicModel.Member<object>("DynamicProperty"));
                set.BindFromExpression(methodLabel, "Text DynamicModel.DynamicMethod(DynamicModel.DynamicProperty)");
                set.BindFromExpression(indexLabel, "Text DynamicModel[DynamicModel.DynamicProperty]");
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;
            CollectionView.BackgroundColor = UIColor.White;
            CollectionView.AllowsMultipleSelection = true;

            using (var set = new BindingSet<TableViewModel>())
            {
                NavigationItem.RightBarButtonItem = new UIBarButtonItem("Invert selection", UIBarButtonItemStyle.Plain, null);
                set.Bind(NavigationItem.RightBarButtonItem).To(() => (vm, ctx) => vm.InvertSelectionCommand);
                set.Bind(CollectionView, AttachedMemberConstants.ItemsSource)
                    .To(() => (vm, ctx) => vm.GridViewModel.ItemsSource);
                CollectionView.SetBindingMemberValue(AttachedMembers.UICollectionView.ItemTemplateSelector, CollectionViewCellTemplateSelector.Instance);
            }
        }
        public RelativeBindingView()
        {
            InitializeComponent();

            using (var set = new BindingSet<RelativeBindingViewModel>())
            {
                set.Bind(trackBarTb)
                   .To<object>(() => (vm, ctx) => ctx.Element<TrackBar>("trackBar").Value)
                   .TwoWay();
                set.Bind(titleTb)
                   .To(() => (vm, ctx) => ctx.Relative<Form>().Text)
                   .TwoWay();
                set.Bind(selfLabel)
                   .ToSelf(() => (label, ctx) => label.Width);
                set.Bind(rootLabel)
                   .To(() => (vm, ctx) => ctx.Root<object>());
            }
        }