Exemple #1
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>();
        }
        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);
            }
        }
Exemple #3
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");
 }
Exemple #4
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);
            }
        }
Exemple #5
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");
            }
        }
        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();
        }
        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();
            }
        }
Exemple #9
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 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 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>();
        }
Exemple #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 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();
        }
        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);
        }
Exemple #15
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, "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'");
            }
        }
Exemple #17
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 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);
        }
        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);
            }
        }
        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");
            }
        }
Exemple #21
0
        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));
                }
            });
        }
Exemple #22
0
        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);
            }
        }
 protected override void Initialize(Button template,
                                    BindingSet <Button, Tuple <string, ViewModelCommandParameter> > bindingSet)
 {
     bindingSet.Bind(() => button => button.Text).To(() => (tuple, ctx) => tuple.Item1);
     bindingSet.Bind()
     .To(() => (tuple, ctx) => ctx.Relative <Form>().DataContext <MainViewModel>().ShowCommand)
     .WithCommandParameter(() => (tuple, ctx) => tuple.Item2);
 }
Exemple #24
0
 protected override void InitializeTemplate(UICollectionView container, CollectionViewCell cell,
                                            BindingSet <CollectionViewCell, TableItemModel> bindingSet)
 {
     bindingSet.BindFromExpression(cell.Label,
                                   "Text $Format('Name {0}, Selected: {1}, Highlighted: {2}', Name, IsSelected, IsHighlighted)");
     bindingSet.Bind(viewCell => viewCell.Selected).To(model => model.IsSelected).TwoWay();
     bindingSet.Bind(viewCell => viewCell.Highlighted).To(model => model.IsHighlighted).TwoWay();
 }
 protected override void InitializeTemplate(UICollectionView container, CollectionViewCell cell,
                                            BindingSet <CollectionViewCell, TableItemModel> bindingSet)
 {
     bindingSet.Bind(cell.Label)
     .To(() => (m, ctx) => string.Format("Name {0}, Selected: {1}, Highlighted: {2}", m.Name, m.IsSelected, m.IsHighlighted));
     bindingSet.Bind(() => viewCell => viewCell.Selected).To(() => (m, ctx) => m.IsSelected).TwoWay();
     bindingSet.Bind(() => viewCell => viewCell.Highlighted).To(() => (m, ctx) => m.IsHighlighted).TwoWay();
 }
Exemple #26
0
 protected override void Initialize(TreeNode template, BindingSet <TreeNode, TreeNodeModel> bindingSet)
 {
     bindingSet.Bind(() => node => node.Text).To(() => (model, ctx) => model.Name);
     bindingSet.Bind(AttachedMemberConstants.ItemsSource).To(() => (model, ctx) => model.Nodes);
     bindingSet.Bind(() => node => node.ForeColor).To(() => (model, ctx) => model.IsValid ? Color.Green : Color.Red);
     template.SetBindingMemberValue(AttachedMembers.Object.ItemTemplateSelector, this);
     template.SetBindingMemberValue(AttachedMembers.Object.CollectionViewManager, TreeNodeCollectionViewManager.Instance);
 }
        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);
            }
        }
 protected override void Initialize(StringElement template,
                                    BindingSet <StringElement, Tuple <string, Type> > bindingSet)
 {
     bindingSet.Bind(() => e => e.Caption).To(() => (t, ctx) => t.Item1).OneTime();
     bindingSet.Bind(AttachedMembers.StringElement.TappedEvent)
     .To(() => (vm, ctx) => ctx.Relative <UIViewController>().DataContext <MainViewModel>().ShowCommand)
     .OneTime()
     .WithCommandParameter(() => (tuple, ctx) => tuple.Item2);
 }
 public ResultView()
 {
     InitializeComponent();
     using (var set = new BindingSet <ResultViewModel>())
     {
         set.Bind(resultTb).To(nameof(ResultViewModel.Result)).TwoWay();
         set.Bind(closeBtn).To(nameof(ResultViewModel.CloseCommand));
     }
 }
        protected override void Initialize(TabPage template, BindingSet <TabPage, ItemViewModel> bindingSet)
        {
            bindingSet.Bind(() => page => page.Text).To(() => (model, ctx) => model.Name);

            var label = new Label();

            bindingSet.Bind(label).To(() => (model, ctx) => model.Id);
            template.Controls.Add(label);
        }
Exemple #31
0
        protected override void OnUIInit()
        {
            viewModel = new DemoViewModel();
            BindingSet <DemoPanel, DemoViewModel> bindingSet = this.CreateBindingSet <DemoPanel, DemoViewModel>(viewModel);

            bindingSet.Bind(this.input_Username).For(v => v.text, v => v.onEndEdit).To(vm => vm.Username);
            bindingSet.Bind(this.confirmButton).For(v => v.onClick).To(vm => vm.LoginCallback);
            bindingSet.Build();
        }
        public override void Bind(BindingSet <LoginViewModel> bindingSet)
        {
            base.Bind(bindingSet);

            bindingSet.Bind(_login).For(v => v.TextAndTextChangedBinding()).To(vm => vm.Login);
            bindingSet.Bind(_password).For(v => v.TextAndTextChangedBinding()).To(vm => vm.Password);
            bindingSet.Bind(_signIn).For(v => v.ClickBinding()).To(vm => vm.SignInCommand);
            bindingSet.Bind(_textView).For(v => v.VisibilityBinding()).To(vm => vm.IsAuthorizationFailed).WithConversion <BoolToVisibilityValueConverter>();
        }
        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));
                }
            });
        }
Exemple #34
0
    protected override void Start()
    {
        BindingSet <CouponView, CouponViewModel> bindingSet = this.CreateBindingSet <CouponView, CouponViewModel>();

        bindingSet.Bind(this.title).For(v => v.text).To(vm => vm.Name).OneWay();

        bindingSet.Bind(this.viewPic).For(v => v.onClick).To(vm => vm.ViewPic).OneWay();

        bindingSet.Build();
    }
Exemple #35
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            using (var set = new BindingSet <MainViewModel>())
            {
                set.Bind(ChangeSomeStringBtn).To(() => (vm, ctx) => vm.ChangeSomeStringCommand);
                set.Bind(this, nameof(SomeString)).To(() => (vm, ctx) => vm.SomeString).TwoWay();
            }
        }
        void ViewBind(CommonScreenFlashView view)
        {
            BindingSet <CommonScreenFlashView, CommonScreenFlashViewModel> bindingSet =
                view.CreateBindingSet <CommonScreenFlashView, CommonScreenFlashViewModel>();

            bindingSet.Bind(view.Show).For(v => v.activeSelf).To(vm => vm.Show).OneWay();
            bindingSet.Bind(view.FlashColor).For(v => v.color).To(vm => vm.FlashColor).OneWay();

            bindingSet.Build();
        }
        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()));
            }
        }
 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);
            }
        }
        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 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>())
            {
                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 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 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 ContentForm()
 {
     InitializeComponent();
     using (var set = new BindingSet<ContentViewModel>())
     {
         set.Bind(this, AttachedMemberConstants.Content).To(() => (vm, ctx) => vm.ViewModel);
     }
 }
        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>()));
            }
        }
 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 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>());
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            TableView.AllowsSelection = true;
            TableView.AllowsMultipleSelection = true;
            TableView.SetCellStyle(UITableViewCellStyle.Subtitle);
            using (var set = new BindingSet<UITableView, TableViewModel>(TableView))
            {
                NavigationItem.RightBarButtonItem = new UIBarButtonItem("Invert selection", UIBarButtonItemStyle.Plain, null);
                set.Bind(NavigationItem.RightBarButtonItem).To(() => model => model.InvertSelectionCommand);

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

                set.Bind(AttachedMemberConstants.ItemsSource)
                   .To(() => model => model.GridViewModel.ItemsSource);
            }

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

                using (var set = new BindingSet<TableItemModel>())
                {
                    set.Bind(cell, () => c => c.Accessory)
                       .ToSelf(() => c => c.Selected)
                       .WithConverter(BooleanToCheckmarkAccessoryConverter.Instance);

                    set.Bind(cell, () => viewCell => viewCell.Selected).To(() => model => model.IsSelected).TwoWay();
                    set.Bind(cell, () => viewCell => viewCell.Highlighted).To(() => model => model.IsHighlighted).OneWayToSource();
                    set.Bind(cell, () => viewCell => viewCell.Editing).To(() => model => model.Editing).OneWayToSource();

                    set.Bind(cell.TextLabel).To(() => model => model.Name);
                    set.Bind(cell.DetailTextLabel)
                        .To(() => m => string.Format("Selected: {0}, Highlighted: {1}, Editing: {2}", m.IsSelected, m.IsHighlighted, m.Editing));
                }
            });
        }
        private static RootElement CreateRootElement()
        {
            using (var bindingSet = new BindingSet<MainViewModel>())
            {
                var root = new RootElement("Main view");
                var section = new Section();
                var element = new MultilineElement(string.Empty);
                bindingSet.Bind(element, () => e => e.Caption)
                    .To(() => (vm, ctx) => vm.ResourceUsageInfo);
                section.Add(element);
                root.Add(section);

                section = new Section("Samples");
                root.Add(section);
                bindingSet.Bind(section, AttachedMemberConstants.ItemsSource).To(() => (vm, ctx) => vm.Items);
                section.SetBindingMemberValue(AttachedMembers.Element.ItemTemplateSelector, ButtonItemTemplate.Instance);
                return root;
            }
        }
 public ProductEditorView()
 {
     InitializeComponent();
     using (var set = new BindingSet<ProductEditorView, ProductEditorViewModel>(this))
     {
         set.Bind(nameTextBox)
            .To(() => m => m.Name)
            .TwoWay()
            .Validate();
         set.Bind(priceTextBox)
            .To(() => m => m.Price)
            .TwoWay()
            .Validate();
         set.Bind(descTextBox)
            .To(() => m => m.Description)
            .TwoWay()
            .Validate();
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            using (var bindingSet = new BindingSet<MainViewModel>())
            {
                bindingSet.Bind(TableView, AttachedMembers.UIView.ItemsSource)
                    .To(() => (vm, ctx) => vm.Items);
                bindingSet.Bind(TableView, AttachedMembers.UITableView.SelectedItemChangedEvent)
                    .To(() => (vm, ctx) => ctx.Relative<UIViewController>().DataContext<MainViewModel>().OpenItemCommand)
                    .WithCommandParameter(() => (item, ctx) => ctx.Self<UITableView>().Member(AttachedMembers.UITableView.SelectedItem));
                TableView.SetCellBind(cell =>
                {
                    cell.TextLabel.Bind(() => l => l.Text)
                        .To<MenuItemModel>(() => (vm, ctx) => vm.Name)
                        .Build();
                });
            }
        }
 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 LocalizableView()
        {
            InitializeComponent();

            using (var set = new BindingSet<LocalizableViewModel>())
            {
                set.Bind(cultureComboBox, AttachedMemberConstants.ItemsSource)
                   .To(() => vm => vm.Cultures);
                set.Bind(cultureComboBox, AttachedMemberConstants.SelectedItem)
                   .To(() => vm => vm.SelectedCulture)
                   .TwoWay();
                set.Bind(addLabel)
                    .To(() => vm => BindingSyntaxEx.Resource<object>(LocalizationManager.ResourceName, () => LocalizableResources.AddText));
                set.Bind(editLabel)
                    .To(() => vm => BindingSyntaxEx.Resource<object>(LocalizationManager.ResourceName, () => LocalizableResources.EditText));
                set.Bind(delLabel)
                    .To(() => vm => BindingSyntaxEx.Resource<object>(LocalizationManager.ResourceName, () => LocalizableResources.DeleteText));
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;
            if (TabBarController != null)
            {
                EdgesForExtendedLayout = UIRectEdge.All;
                TableView.ContentInset = new UIEdgeInsets(
                        UIApplication.SharedApplication.StatusBarFrame.Height +
                        NavigationController.NavigationBar.Frame.Height, 0f, TabBarController.TabBar.Frame.Height, 0f);
            }

            using (var set = new BindingSet<OrderEditorViewModel>())
            {
                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(TableView, AttachedMembers.UIView.ItemsSource).To(() => (vm, ctx) => vm.GridViewModel.ItemsSource);
            }

            TableView.AllowsMultipleSelection = true;
            TableView.SetCellStyle(UITableViewCellStyle.Subtitle);
            TableView.SetCellBind(cell =>
            {
                cell.SetEditingStyle(UITableViewCellEditingStyle.None);
                cell.Accessory = UITableViewCellAccessory.None;
                using (var set = new BindingSet<SelectableWrapper<ProductModel>>())
                {
                    set.Bind(cell, () => viewCell => viewCell.Selected)
                       .To(() => (vm, ctx) => vm.IsSelected)
                       .TwoWay();
                    set.Bind(cell.TextLabel)
                       .To(() => (vm, ctx) => vm.Model.Name);
                    set.Bind(cell.DetailTextLabel)
                       .To(() => (vm, ctx) => vm.Model.Description);
                    set.Bind(cell, () => v => v.Accessory)
                        .ToSelf(() => (vm, ctx) => vm.Selected)
                        .WithConverter(BooleanToCheckmarkAccessoryConverter.Instance);
                }
            });
        }