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 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);
            }
        }
        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 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 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 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 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 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 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 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 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 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);
                }
            });
        }
 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 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 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 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 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 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 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 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>());
            }
        }