예제 #1
0
        static PlatformDataBindingModule()
        {
            AddViewValue    = new object();
            RemoveViewValue = new object[] { null };
            //Menu
            MenuItemsSourceMember   = AttachedBindingMember.CreateAutoProperty <IMenu, IEnumerable>(AttachedMemberConstants.ItemsSource, MenuItemsSourceChanged);
            IsCheckedMenuItemMember = AttachedBindingMember.CreateNotifiableMember <IMenuItem, bool>("IsChecked",
                                                                                                     (info, item) => item.IsChecked, (info, item, value) =>
            {
                if (value == item.IsChecked)
                {
                    return(false);
                }
                item.SetChecked(value);
                return(true);
            });
#if !API8
            MenuItemActionViewMember = AttachedBindingMember
                                       .CreateNotifiableMember <IMenuItem, object>("ActionView", (info, item) => item.GetActionView(), MenuItemUpdateActionView);
            MenuItemActionViewSelectorMember = AttachedBindingMember
                                               .CreateAutoProperty <IMenuItem, IDataTemplateSelector>("ActionViewTemplateSelector", (o, args) => RefreshValue(o, MenuItemActionViewMember));

            MenuItemActionProviderMember = AttachedBindingMember
                                           .CreateNotifiableMember <IMenuItem, object>("ActionProvider", (info, item) => item.GetActionProvider(), MenuItemUpdateActionProvider);
            MenuItemActionProviderSelectorMember = AttachedBindingMember
                                                   .CreateAutoProperty <IMenuItem, IDataTemplateSelector>("ActionProviderTemplateSelector", (o, args) => RefreshValue(o, MenuItemActionProviderMember));

            AddToBackStackMember = AttachedBindingMember.CreateAutoProperty <ViewGroup, bool>("AddToBackStack");
#endif
            //ViewGroup
            ContentMember = AttachedBindingMember
                            .CreateAutoProperty <ViewGroup, object>(AttachedMemberConstants.Content, ContentMemberChanged, ContentMemberAttached);
            ContentTemplateIdMember = AttachedBindingMember
                                      .CreateAutoProperty <ViewGroup, int?>(AttachedMemberConstants.ContentTemplate, ContentTemplateIdChanged);
            ContentTemplateSelectorMember = AttachedBindingMember
                                            .CreateAutoProperty <ViewGroup, IDataTemplateSelector>(AttachedMemberConstants.ContentTemplateSelector, ContentTemplateSelectorChanged);

            //AdapterView
            AdapterViewSelectedPositionMember =
                AttachedBindingMember.CreateAutoProperty <AdapterView, int>("SelectedItemPosition",
                                                                            AdapterViewSelectedItemPositionChanged, AdapterViewSelectedMemberAttached, (view, info) => view.SelectedItemPosition);
            AdapterViewSelectedItemMember = AttachedBindingMember.CreateAutoProperty <AdapterView, object>(
                AttachedMemberConstants.SelectedItem, AdapterViewSelectedItemChanged);
            ScrollToSelectedItemMember = AttachedBindingMember.CreateAutoProperty <AdapterView, bool>("ScrollToSelectedItem");

            //TabHost
            TabHostSelectedItemMember = AttachedBindingMember.CreateAutoProperty <TabHost, object>(AttachedMemberConstants.SelectedItem, TabHostSelectedItemChanged);

#if !API8
            //Action bar
            ActionBarItemsSourceMember  = AttachedBindingMember.CreateAutoProperty <ActionBar, IEnumerable>(AttachedMemberConstants.ItemsSource, (bar, args) => ActionBarUpdateItemsSource(bar));
            ActionBarSelectedItemMember = AttachedBindingMember.CreateAutoProperty <ActionBar, object>(AttachedMemberConstants.SelectedItem, ActionBarSelectedItemChanged);
            //Context action bar
            ActionBarContextActionBarTemplateMember = AttachedBindingMember.CreateAutoProperty <ActionBar, int?>("ContextActionBarTemplate");
            ActionBarContextActionBarVisibleMember  = AttachedBindingMember.CreateAutoProperty <ActionBar, bool>("ContextActionBarVisible", ActionBarContextActionBarVisibleChanged);

            //ActioBar.Tab
            ActionBarTabContentMember = AttachedBindingMember.CreateAutoProperty <ActionBar.Tab, object>(AttachedMemberConstants.Content);
#endif
        }
        public void CreateNotifiableMemberGenericObserveTest()
        {
            bool isInvoked    = false;
            bool raiseEvent   = true;
            var  listenerMock = new EventListenerMock
            {
                Handle = (o, o1) => isInvoked = true
            };
            var          source   = new BindingSourceModel();
            const string path     = "path";
            var          property = AttachedBindingMember.CreateNotifiableMember <BindingSourceModel, string>(path, (info, o) => null,
                                                                                                              (info, o, v) => raiseEvent);

            IDisposable subscriber = property.TryObserve(source, listenerMock);

            property.SetValue(source, new object[] { path });
            isInvoked.ShouldBeTrue();
            subscriber.ShouldNotBeNull();

            raiseEvent = false;
            isInvoked  = false;
            property.SetValue(source, new object[] { path });
            isInvoked.ShouldBeFalse();

            raiseEvent = true;
            isInvoked  = false;
            property.SetValue(source, new object[] { null });
            isInvoked.ShouldBeTrue();

            subscriber.Dispose();
            isInvoked = false;
            property.SetValue(source, new object[] { path });
            isInvoked.ShouldBeFalse();
        }
        public void CreateNotifiableMemberGenericSetterTest()
        {
            object       value    = null;
            var          source   = new BindingSourceModel();
            const string path     = "path";
            Type         type     = typeof(string);
            var          property = AttachedBindingMember.CreateNotifiableMember <BindingSourceModel, string>(path, null, (info, o, v) =>
            {
                info.ShouldNotBeNull();
                o.ShouldEqual(source);
                v.ShouldEqual(path);
                value = v;
                return(true);
            });

            property.Path.ShouldEqual(path);
            property.Type.ShouldEqual(type);
            property.CanRead.ShouldBeFalse();
            property.CanWrite.ShouldBeTrue();
            property.MemberType.ShouldEqual(BindingMemberType.Attached);

            property.SetValue(source, new object[] { path });
            value.ShouldEqual(path);
            ShouldThrow(() => property.GetValue(source, null));
        }
        public void CreateNotifiableMemberGenericTest()
        {
            string       value    = null;
            var          source   = new BindingSourceModel();
            const string path     = "path";
            Type         type     = typeof(string);
            var          property = AttachedBindingMember.CreateNotifiableMember <BindingSourceModel, string>(path, (info, o) => value,
                                                                                                              (info, o, v) =>
            {
                value = v;
                return(true);
            }, member: BindingSourceModel.IntPropertyInfo);

            property.Path.ShouldEqual(path);
            property.Type.ShouldEqual(type);
            property.CanRead.ShouldBeTrue();
            property.CanWrite.ShouldBeTrue();
            property.MemberType.ShouldEqual(BindingMemberType.Attached);
            property.Member.ShouldEqual(BindingSourceModel.IntPropertyInfo);

            property.GetValue(source, null).ShouldBeNull();
            property.SetValue(source, new object[] { path });
            property.GetValue(source, null).ShouldEqual(path);
            value.ShouldEqual(path);
        }
 public static void RegisterSplitViewControllerMembers()
 {
     MemberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.UISplitViewController.MasterView,
                                                                          (info, controller) =>
     {
         if (controller.ViewControllers.Length == 2)
         {
             return(controller.ViewControllers[0]);
         }
         return(null);
     }, (info, controller, arg3) =>
     {
         UpdateMasterDetailController(controller, arg3, true);
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.UISplitViewController.DetailView,
                                                                          (info, controller) =>
     {
         if (controller.ViewControllers.Length == 2)
         {
             return(controller.ViewControllers[1]);
         }
         return(null);
     }, (info, controller, arg3) =>
     {
         UpdateMasterDetailController(controller, arg3, false);
         return(true);
     }));
 }
예제 #6
0
        public static void RegisterDefaultMembers()
        {
            var memberProvider = BindingServiceProvider.MemberProvider;
            var registration   = new DefaultAttachedMemberRegistration <object>(CommandParameterInternal, AttachedMemberConstants.CommandParameter);

            memberProvider.Register(registration.ToAttachedBindingMember <object>());
            var parentMember = AttachedBindingMember.CreateMember <object, object>(AttachedMemberConstants.Parent, GetParent, SetParent, ObserveParent, ParentAttached);

            AttachedBindingMember.TrySetRaiseAction(parentMember, (info, o, arg3) => AttachedParentMember.Raise(o, arg3));
            memberProvider.Register(parentMember);
            memberProvider.Register(AttachedBindingMember.CreateMember <object, object>("Root", GetRootMember, null, ObserveRootMember));

            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember <object, IEnumerable <object> >(AttachedMemberConstants.ErrorsPropertyMember, GetErrors, SetErrors));
            memberProvider.Register(AttachedBindingMember.CreateMember <object, bool>("HasErrors", GetHasErrors, null, ObserveHasErrors));
        }
        public static void RegisterDefaultMembers()
        {
            var memberProvider = BindingServiceProvider.MemberProvider;
            var registration   = new DefaultAttachedMemberRegistration <object>(CommandParameterInternal, AttachedMemberConstants.CommandParameter);

            memberProvider.Register(registration.ToAttachedBindingMember <object>());
            var parentMember = AttachedBindingMember.CreateMember(AttachedMembersBase.Object.Parent, GetParent, SetParent, ObserveParent, ParentAttached);

            AttachedBindingMember.TrySetRaiseAction(parentMember, (info, o, arg3) => AttachedParentMember.Raise(o, arg3));
            memberProvider.Register(parentMember);
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembersBase.Object.Root, GetRootMember, null, ObserveRootMember));

            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembersBase.Object.Errors, GetErrors, SetErrors));
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembersBase.Object.HasErrors, GetHasErrors, null, ObserveHasErrors));

            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersBase.Object.IsFlatTree));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersBase.Object.IsFlatContext));
        }
예제 #8
0
 public static void RegisterActionBarBaseMembers()
 {
     MemberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, object>(AttachedMemberConstants.ParentExplicit, (info, bar) => bar.ThemedContext.GetActivity(), null));
     MemberProvider.Register(AttachedBindingMember
                             .CreateNotifiableMember <ActionBar, string>(nameof(ActionBar.Subtitle),
                                                                         (info, actionBar) => actionBar.Subtitle, (info, actionBar, value) =>
     {
         actionBar.Subtitle = value;
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember
                             .CreateNotifiableMember <ActionBar, string>(nameof(ActionBar.Title),
                                                                         (info, actionBar) => actionBar.Title, (info, actionBar, value) =>
     {
         actionBar.Title = value;
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, HomeButtonImpl>("HomeButton", (info, bar) => HomeButtonImpl.GetOrAdd(bar), null));
     MemberProvider.Register(AttachedBindingMember.CreateEvent <HomeButtonImpl>("Click", (info, homeButton, arg3) => homeButton.AddWithUnsubscriber(arg3)));
 }
        public void CreateNotifiableMemberGenericGetterTest()
        {
            var          args     = new object[0];
            const string value    = "1";
            var          source   = new BindingSourceModel();
            const string path     = "path";
            Type         type     = typeof(string);
            var          property = AttachedBindingMember.CreateNotifiableMember <BindingSourceModel, string>(path, (info, o) =>
            {
                info.ShouldNotBeNull();
                o.ShouldEqual(source);
                return(value);
            }, (info, o, v) => true);

            property.Path.ShouldEqual(path);
            property.Type.ShouldEqual(type);
            property.CanRead.ShouldBeTrue();
            property.CanWrite.ShouldBeTrue();
            property.MemberType.ShouldEqual(BindingMemberType.Attached);
            property.GetValue(source, args).ShouldEqual(value);
        }
 public static void RegisterTabLayoutTabMembers()
 {
     MemberProvider.Register(AttachedBindingMember.CreateNotifiableMember <TabLayout.Tab, string>(nameof(TabLayout.Tab.Text),
                                                                                                  (info, tab) => tab.Text,
                                                                                                  (info, tab, arg3) =>
     {
         tab.SetText(arg3);
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember.CreateNotifiableMember <TabLayout.Tab, string>(nameof(TabLayout.Tab.ContentDescription),
                                                                                                  (info, tab) => tab.ContentDescription,
                                                                                                  (info, tab, arg3) =>
     {
         tab.SetContentDescription(arg3);
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember.CreateNotifiableMember <TabLayout.Tab, object>(nameof(TabLayout.Tab.Icon),
                                                                                                  (info, tab) => tab.Icon,
                                                                                                  (info, tab, arg3) =>
     {
         if (arg3 is int)
         {
             tab.SetIcon((int)arg3);
         }
         else
         {
             tab.SetIcon((Drawable)arg3);
         }
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember.CreateNotifiableMember <TabLayout.Tab, Object>(nameof(TabLayout.Tab.Tag),
                                                                                                  (info, tab) => tab.Tag,
                                                                                                  (info, tab, arg3) =>
     {
         tab.SetTag(arg3);
         return(true);
     }));
 }
예제 #11
0
        private static void RegisterDefaultMembers()
        {
            ViewManager.GetDataContext = BindingExtensions.DataContext;
            ViewManager.SetDataContext = BindingExtensions.SetDataContext;

            var memberProvider = BindingServiceProvider.MemberProvider;

            var registration = new DefaultAttachedMemberRegistration <object>(CommandParameterInternal, AttachedMemberConstants.CommandParameter);

            memberProvider.Register(registration.ToAttachedBindingMember <object>());
            var parentMember = AttachedBindingMember.CreateMember <object, object>(AttachedMemberConstants.Parent, GetParent, SetParent, ObserveParent, ParentAttached);

            AttachedBindingMember.TrySetRaiseAction(parentMember, (info, o, arg3) => AttachedParentMember.Raise(o, arg3));
            memberProvider.Register(parentMember);
            memberProvider.Register(AttachedBindingMember.CreateMember <object, object>("Root", GetRootMember, null, ObserveRootMember));

            var errorsMember = AttachedBindingMember.CreateNotifiableMember <object, IEnumerable <object> >(AttachedMemberConstants.ErrorsPropertyMember, GetErrors, SetErrors);

            memberProvider.Register(errorsMember, true);
            memberProvider.Register(AttachedBindingMember.CreateMember <object, bool>("HasErrors", GetHasErrors, null, ObserveHasErrors));
            memberProvider.Register(typeof(object), ErrorProviderErrors, errorsMember, true);
            memberProvider.Register(typeof(object), "BindingErrorProvider.Errors", errorsMember, true);
        }
        public void CreateNotifiableMemberGenericMemberAttachTest()
        {
            bool         isInvoked = false;
            var          source    = new BindingSourceModel();
            const string path      = "path";
            var          property  = AttachedBindingMember.CreateNotifiableMember <BindingSourceModel, string>(path, (info, o) => null, (info, o, v) => true,
                                                                                                               (model, args) =>
            {
                model.ShouldEqual(source);
                args.ShouldNotBeNull();
                isInvoked = true;
            });

            property.SetValue(source, new object[] { path });
            isInvoked.ShouldBeTrue();

            isInvoked = false;
            property.SetValue(source, new object[] { null });
            isInvoked.ShouldBeFalse();

            source = new BindingSourceModel();
            property.SetValue(source, new object[] { path });
            isInvoked.ShouldBeTrue();
        }
        private static void RegisterActionBarMembers(IBindingMemberProvider memberProvider)
        {
            memberProvider.Register(ActionBarTabContentMember);
            memberProvider.Register(ActionBarSelectedItemMember);
            memberProvider.Register(ActionBarItemsSourceMember);
            memberProvider.Register(ActionBarContextActionBarTemplateMember);
            memberProvider.Register(ActionBarContextActionBarVisibleMember);

            memberProvider.Register(AttachedBindingMember
                                    .CreateMember <ActionBar, object>(AttachedMemberConstants.Parent, (info, bar) => bar.ThemedContext.GetActivity(), null));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, object>("BackgroundDrawable",
                                                                            (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetBackgroundDrawable(
                        actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue));
                }
                else
                {
                    actionBar.SetBackgroundDrawable((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar, object>("CustomView",
                                                                                (info, actionBar) => actionBar.CustomView,
                                                                                (info, actionBar, value) =>
            {
                if (actionBar.CustomView != null)
                {
                    ParentObserver.GetOrAdd(actionBar.CustomView).Parent = null;
                }
                if (value is int)
                {
                    actionBar.SetCustomView((int)value);
                }
                else
                {
                    actionBar.CustomView = (View)value;
                }
                if (actionBar.CustomView != null)
                {
                    ParentObserver.GetOrAdd(actionBar.CustomView).Parent = actionBar;
                }
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, bool>("DisplayHomeAsUpEnabled",
                                                                          (actionBar, args) => actionBar.SetDisplayHomeAsUpEnabled(args.NewValue)));

            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar, ActionBarDisplayOptions>("DisplayOptions",
                                                                                                 (info, actionBar) => actionBar.GetActionBarDisplayOptions(),
                                                                                                 (info, actionBar, value) =>
            {
                actionBar.SetActionBarDisplayOptions(value);
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, bool>("DisplayShowCustomEnabled",
                                                                          (actionBar, args) => actionBar.SetDisplayShowCustomEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, bool>("DisplayShowHomeEnabled",
                                                                          (actionBar, args) => actionBar.SetDisplayShowHomeEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, bool>("DisplayShowTitleEnabled",
                                                                          (actionBar, args) => actionBar.SetDisplayShowTitleEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, bool>("DisplayUseLogoEnabled",
                                                                          (actionBar, args) => actionBar.SetDisplayUseLogoEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, bool>("HomeButtonEnabled",
                                                                          (actionBar, args) => actionBar.SetHomeButtonEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, object>("Icon", (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetIcon((int)args.NewValue);
                }
                else
                {
                    actionBar.SetIcon((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, object>("Logo", (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetLogo((int)args.NewValue);
                }
                else
                {
                    actionBar.SetLogo((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar, ActionBarNavigationMode>("NavigationMode",
                                                                                                 (info, actionBar) => actionBar.GetNavigationMode(), ActionBarSetNavigationMode));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, object>("SplitBackgroundDrawable",
                                                                            (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetSplitBackgroundDrawable(
                        actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue));
                }
                else
                {
                    actionBar.SetSplitBackgroundDrawable((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty <ActionBar, object>("StackedBackgroundDrawable",
                                                                            (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetStackedBackgroundDrawable(
                        actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue));
                }
                else
                {
                    actionBar.SetStackedBackgroundDrawable((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar, bool>("IsShowing", (info, actionBar) => actionBar.IsShowing, SetActionBarIsShowing));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar, string>("Subtitle",
                                                                                (info, actionBar) => actionBar.Subtitle, (info, actionBar, value) =>
            {
                actionBar.Subtitle = value;
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar, string>("Title",
                                                                                (info, actionBar) => actionBar.Title, (info, actionBar, value) =>
            {
                actionBar.Title = value;
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar, bool>("Visible", (info, actionBar) => actionBar.IsShowing, SetActionBarIsShowing));
            memberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, View>("HomeButton", GetHomeButton, null));

            memberProvider.Register(
                AttachedBindingMember.CreateAutoProperty <ActionBar, int?>(AttachedMemberNames.DropDownItemTemplate));
            memberProvider.Register(
                AttachedBindingMember.CreateAutoProperty <ActionBar, IDataTemplateSelector>(
                    AttachedMemberNames.DropDownItemTemplateSelector));

            //ActionBar.Tab
            memberProvider.Register(
                AttachedBindingMember.CreateAutoProperty <ActionBar.Tab, IDataTemplateSelector>(
                    AttachedMemberConstants.ContentTemplateSelector));
            memberProvider.Register(
                AttachedBindingMember.CreateAutoProperty <ActionBar.Tab, int?>(
                    AttachedMemberConstants.ContentTemplate));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar.Tab, string>("ContentDescription",
                                                                                    (info, tab) => tab.ContentDescription,
                                                                                    (info, tab, value) =>
            {
                tab.SetContentDescription(value);
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar.Tab, object>("CustomView",
                                                                                    (info, tab) => tab.CustomView, (info, tab, value) =>
            {
                if (tab.CustomView != null)
                {
                    ParentObserver.GetOrAdd(tab.CustomView).Parent = null;
                }
                if (value is int)
                {
                    tab.SetCustomView((int)value);
                }
                else
                {
                    tab.SetCustomView((View)value);
                }
                if (tab.CustomView != null)
                {
                    ParentObserver.GetOrAdd(tab.CustomView).Parent = tab;
                }
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar.Tab, object>("Icon",
                                                                                    (info, tab) => tab.Icon, (info, tab, value) =>
            {
                if (value is int)
                {
                    tab.SetIcon((int)value);
                }
                else
                {
                    tab.SetIcon((Drawable)value);
                }
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar.Tab, string>("Text",
                                                                                    (info, tab) => tab.Text,
                                                                                    (info, tab, value) =>
            {
                tab.SetText(value);
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar.Tab, Object>("Tag",
                                                                                    (info, tab) => tab.Tag,
                                                                                    (info, tab, value) =>
            {
                tab.SetTag(value);
                return(true);
            }));

            //SearchView
            var queryMember = AttachedBindingMember.CreateMember <SearchView, string>("Query",
                                                                                      (info, searchView) => searchView.Query,
                                                                                      (info, searchView, value) => searchView.SetQuery(value, false), "QueryTextChange");

            memberProvider.Register(queryMember);
            memberProvider.Register("Text", queryMember);
        }
        private static void RegisterCollectionViewMembers(IBindingMemberProvider memberProvider)
        {
            BindingServiceProvider.ResourceResolver.AddType(typeof(UICollectionViewScrollPosition));
            BindingServiceProvider.ResourceResolver.AddType(typeof(UICollectionViewScrollDirection));

            BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UICollectionView.UseAnimations]  = BindingServiceProvider.TemplateMemberPriority + 1;
            BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UICollectionView.ScrollPosition] = BindingServiceProvider.TemplateMemberPriority + 1;

            //UICollectionView
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIView.ItemsSource.Override <UICollectionView>());
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionView.UseAnimations));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionView.ScrollPosition));
            memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UICollectionView.SelectedItemChangedEvent));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ItemsSource.Override <UICollectionView>(), CollectionViewItemsSourceChanged));
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UICollectionView.SelectedItem,
                                                                       GetCollectionViewSelectedItem, SetCollectionViewSelectedItem, (info, view, arg3) => (IDisposable)view.SetBindingMemberValue(AttachedMembers.UICollectionView.SelectedItemChangedEvent, arg3)));
            var itemTemplateMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionView.ItemTemplateSelector, (view, args) => args.NewValue?.Initialize(view));

            memberProvider.Register(itemTemplateMember);
            memberProvider.Register(typeof(UICollectionView), AttachedMemberConstants.ItemTemplate, itemTemplateMember, true);

            //UICollectionViewCell
            memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UICollectionViewCell.ClickEvent));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.UICollectionViewCell.Selected, (info, cell) =>
            {
                if (CollectionViewSourceBase.HasMask(cell, CollectionViewSourceBase.InitializingStateMask))
                {
                    return(null);
                }
                var cellBindable = cell as UICollectionViewCellBindable;
                if (cellBindable == null)
                {
                    return(cell.Selected);
                }
                return(cellBindable.SelectedBind.GetValueOrDefault());
            },
                                                            (info, cell, arg3) =>
            {
                var cellBindable = cell as UICollectionViewCellBindable;
                if (cellBindable == null)
                {
                    cell.Selected = arg3.GetValueOrDefault();
                }
                else
                {
                    cellBindable.SelectedBind = arg3;
                }
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.UICollectionViewCell.Highlighted, (info, cell) => cell.Highlighted,
                                                            (info, cell, arg3) =>
            {
                cell.Highlighted = arg3;
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionViewCell.ShouldHighlight));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionViewCell.ShouldDeselect));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UICollectionViewCell.ShouldSelect));
        }
        private static void RegisterTableViewMembers(IBindingMemberProvider memberProvider)
        {
            BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewRowAnimation));
            BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewScrollPosition));
            BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellEditingStyle));
            BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellAccessory));
            BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellSelectionStyle));
            BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellSeparatorStyle));
            BindingServiceProvider.ResourceResolver.AddType(typeof(UITableViewCellStyle));

            BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.UseAnimations]    = BindingServiceProvider.TemplateMemberPriority + 1;
            BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.AddAnimation]     = BindingServiceProvider.TemplateMemberPriority + 1;
            BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.RemoveAnimation]  = BindingServiceProvider.TemplateMemberPriority + 1;
            BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.ReplaceAnimation] = BindingServiceProvider.TemplateMemberPriority + 1;
            BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UITableView.ScrollPosition]   = BindingServiceProvider.TemplateMemberPriority + 1;

            //UITableView
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIView.ItemsSource.Override <UITableView>());
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ReadOnly));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.AddAnimation));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.RemoveAnimation));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ReplaceAnimation));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ScrollPosition));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.UseAnimations));
            memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableView.SelectedItemChangedEvent));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ItemsSource.Override <UITableView>(), TableViewItemsSourceChanged));
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UITableView.SelectedItem,
                                                                       GetTableViewSelectedItem, SetTableViewSelectedItem, (info, view, arg3) => (IDisposable)view.SetBindingMemberValue(AttachedMembers.UITableView.SelectedItemChangedEvent, arg3)));
            var itemTemplateMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableView.ItemTemplateSelector, (view, args) => args.NewValue?.Initialize(view));

            memberProvider.Register(itemTemplateMember);
            memberProvider.Register(typeof(UITableView), AttachedMemberConstants.ItemTemplate, itemTemplateMember, true);

            //UITableViewCell
            BindingBuilderExtensions.RegisterDefaultBindingMember <UITableViewCell>(() => c => c.TextLabel.Text);
            var member = AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.AccessoryButtonTappedEvent);

            memberProvider.Register(member);
            memberProvider.Register("Click", member);
            memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.DeleteClickEvent));
            memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.InsertClickEvent));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.Moveable));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.TitleForDeleteConfirmation));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.EditingStyle));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITableViewCell.ShouldHighlight));
            memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITableViewCell.ClickEvent));
            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(
                                        AttachedMembers.UITableViewCell.Selected, (info, cell) =>
            {
                if (TableViewSourceBase.HasMask(cell, TableViewSourceBase.InitializingStateMask))
                {
                    return(null);
                }
                var cellBindable = cell as UITableViewCellBindable;
                if (cellBindable == null)
                {
                    return(cell.Selected);
                }
                return(cellBindable.SelectedBind.GetValueOrDefault());
            }, (info, cell, arg3) =>
            {
                var cellBindable = cell as UITableViewCellBindable;
                if (cellBindable == null)
                {
                    cell.Selected = arg3.GetValueOrDefault();
                }
                else
                {
                    cellBindable.SelectedBind = arg3;
                }
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(
                                        AttachedMembers.UITableViewCell.Highlighted, (info, cell) => cell.Highlighted,
                                        (info, cell, arg3) =>
            {
                if (cell.Highlighted == arg3)
                {
                    return(false);
                }
                cell.Highlighted = arg3;
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(
                                        AttachedMembers.UITableViewCell.Editing, (info, cell) => cell.Editing,
                                        (info, cell, arg3) =>
            {
                if (cell.Editing == arg3)
                {
                    return(false);
                }
                cell.Editing = arg3;
                return(true);
            }));
        }
예제 #16
0
        private static void Register(IBindingMemberProvider memberProvider)
        {
            BindingServiceProvider.ResourceResolver.AddType(typeof(UITextFieldViewMode));
            RegisterTableViewMembers(memberProvider);
            RegisterCollectionViewMembers(memberProvider);
            RegisterDialogMembers(memberProvider);
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIBarButtonItem.ClickEvent);
            BindingBuilderExtensions.RegisterDefaultBindingMember <UISearchBar>(() => t => t.Text);
            BindingBuilderExtensions.RegisterDefaultBindingMember <UISlider>(() => t => t.Value);
            BindingBuilderExtensions.RegisterDefaultBindingMember <UIProgressView>(() => t => t.Progress);

            //Object
            var itemsSourceMember         = AttachedBindingMember.CreateAutoProperty <object, IEnumerable>(AttachedMemberConstants.ItemsSource, ObjectItemsSourceChanged);
            var defaultMemberRegistration = new DefaultAttachedMemberRegistration <IEnumerable>(itemsSourceMember);

            memberProvider.Register(defaultMemberRegistration.ToAttachedBindingMember <object>());
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty <object, ICollectionViewManager>(AttachedMembers.UIView.CollectionViewManager.Path));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty <object, IContentViewManager>(AttachedMembers.UIView.ContentViewManager.Path));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(ItemsSourceGeneratorBase.MemberDescriptor,
                                                                             (o, args) =>
            {
                IEnumerable itemsSource = null;
                if (args.OldValue != null)
                {
                    itemsSource = args.OldValue.ItemsSource;
                    args.OldValue.SetItemsSource(null);
                }
                if (args.NewValue != null)
                {
                    args.NewValue.SetItemsSource(itemsSource);
                }
            }));

            var itemTemplateMember = AttachedBindingMember.CreateAutoProperty <object, IDataTemplateSelector>(AttachedMemberConstants.ItemTemplateSelector);

            memberProvider.Register(itemTemplateMember);
            memberProvider.Register(typeof(object), AttachedMemberConstants.ItemTemplate, itemTemplateMember, true);

            //UIView
            memberProvider.Register(AttachedBindingMember.CreateMember <UIView, object>(AttachedMemberConstants.Parent,
                                                                                        (info, view) => ParentObserver.GetOrAdd(view).Parent, (info, view, arg3) => ParentObserver.GetOrAdd(view).Parent = arg3, (info, view, arg3) => ParentObserver.GetOrAdd(view).AddWithUnsubscriber(arg3)));
            memberProvider.Register(AttachedBindingMember.CreateMember <UIView, object>(AttachedMemberConstants.FindByNameMethod, FindViewByName));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.Content, ContentChanged));
            var member = AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ContentTemplateSelector, ContentTemplateChanged);

            memberProvider.Register(member);
            memberProvider.Register(typeof(UIView), AttachedMemberConstants.ContentTemplate, member, true);
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIView.Visible, (info, view) => !view.Hidden, (info, view, arg3) => view.Hidden = !arg3));

            //UISegmentedControl
            BindingBuilderExtensions.RegisterDefaultBindingMember <UISegmentedControl>(() => t => t.SelectedSegment);
            memberProvider.Register(AttachedBindingMember.CreateMember <UISegmentedControl, int>("SelectedSegment",
                                                                                                 (info, control) => (int)control.SelectedSegment,
                                                                                                 (info, control, arg3) => control.SelectedSegment = arg3, "ValueChanged"));

            //UIButton
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIControl.ClickEvent.Override <UIButton>());
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIButton.Title,
                                                                       (info, button) => button.CurrentTitle,
                                                                       (info, button, arg3) => button.SetTitle(arg3, button.State)));
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIButton.State,
                                                                       (info, button) => button.State,
                                                                       (info, button, arg3) => button.SetTitle(button.CurrentTitle, arg3)));

            //UIDatePicker
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIDatePicker.Date);
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIDatePicker.Date,
                                                                       (info, picker) => NSDateToDateTime(picker.Date), (info, picker, arg3) => picker.Date = DateTimeToNSDate(arg3), "ValueChanged"));

            //UISwitch
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UISwitch.On);
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UISwitch.On,
                                                                       (info, picker) => picker.On, (info, picker, arg3) => picker.On = arg3, "ValueChanged"));

            //UIControl
            var clickMember = memberProvider.GetBindingMember(typeof(UIControl), "TouchUpInside", true, false);

            if (clickMember != null)
            {
                memberProvider.Register(typeof(UIControl), "Click", clickMember, true);
            }

            //UITextField
            BindingBuilderExtensions.RegisterDefaultBindingMember <UITextField>(() => t => t.Text);
            NSNotificationCenter.DefaultCenter.AddObserver(UITextField.TextFieldTextDidChangeNotification, TextDidChangeNotification);
            memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITextField.TextChangedEvent, SetTextFieldTextChanged));

            //UITextView
            BindingBuilderExtensions.RegisterDefaultBindingMember <UITextView>(() => t => t.Text);
            NSNotificationCenter.DefaultCenter.AddObserver(UITextView.TextDidChangeNotification, TextDidChangeNotification);
            memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.UITextView.TextChangedEvent, SetTextFieldTextChanged));

            //UILabel
            BindingBuilderExtensions.RegisterDefaultBindingMember <UILabel>(() => t => t.Text);
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UILabel.TextSizeToFit,
                                                                       (info, label) => label.Text,
                                                                       (info, label, arg3) =>
            {
                label.Text = arg3;
                label.SizeToFit();
            }));

            //UIViewController
            BindingServiceProvider.BindingMemberPriorities["ToolbarItemTemplate"] = BindingServiceProvider.TemplateMemberPriority;
            BindingServiceProvider.BindingMemberPriorities[AttachedMembers.UIViewController.ToolbarItemTemplateSelector] = BindingServiceProvider.TemplateMemberPriority;
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIViewController.ToastTemplateSelector));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIViewController.ToolbarItemsSource, ToolbarItemsSourceChanged));
            var templateMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIViewController.ToolbarItemTemplateSelector);

            memberProvider.Register(templateMember);
            memberProvider.Register(typeof(UIViewController), "ToolbarItemTemplate", templateMember, true);
            memberProvider.Register(AttachedBindingMember.CreateMember <UIViewController, string>("Title",
                                                                                                  (info, controller) => controller.Title,
                                                                                                  (info, controller, arg3) => controller.Title = arg3 ?? string.Empty));
            memberProvider.Register(AttachedBindingMember.CreateMember <UIViewController, object>(AttachedMemberConstants.ParentExplicit,
                                                                                                  (info, controller) => controller.ParentViewController ?? controller.PresentingViewController ?? controller.SplitViewController, null));

            //UITabBarController
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UITabBarController.ItemsSource);
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITabBarController.SelectedItem, TabBarSelectedItemChanged, TabBarSelectedItemAttached));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UITabBarController.ItemsSource, TabBarItemsSourceChanged));

            //UISplitViewController
            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.UISplitViewController.MasterView,
                                                                                 (info, controller) =>
            {
                if (controller.ViewControllers.Length == 2)
                {
                    return(controller.ViewControllers[0]);
                }
                return(null);
            }, (info, controller, arg3) =>
            {
                UpdateMasterDetailController(controller, arg3, true);
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.UISplitViewController.DetailView,
                                                                                 (info, controller) =>
            {
                if (controller.ViewControllers.Length == 2)
                {
                    return(controller.ViewControllers[1]);
                }
                return(null);
            }, (info, controller, arg3) =>
            {
                UpdateMasterDetailController(controller, arg3, false);
                return(true);
            }));

            //UIToolbar
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIView.ItemsSource.Override <UIToolbar>());
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ItemsSource.Override <UIToolbar>(), ToolbarItemsSourceChanged));

            //UIPickerView
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.UIView.ItemsSource.Override <UIPickerView>());
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIView.ItemsSource.Override <UIPickerView>(), PickerViewItemsSourceChanged));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.UIPickerView.DisplayMemberPath, PickerViewDisplayMemberPathChangedChanged));
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.UIPickerView.SelectedItem,
                                                                       (info, view) => GetOrAddPickerViewModel(view).SelectedItem,
                                                                       (info, view, arg3) => GetOrAddPickerViewModel(view).SelectedItem = arg3, (info, view, arg3) =>
            {
                var viewModel = GetOrAddPickerViewModel(view);
                return(BindingServiceProvider.WeakEventManager.TrySubscribe(viewModel, "SelectedItemChanged", arg3));
            }));
        }
예제 #17
0
 public static void RegisterMenuItemActionProviderMembers()
 {
     MemberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.MenuItem.ActionProvider, (info, item) => item.GetActionProvider(), MenuItemUpdateActionProvider));
     MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.MenuItem.ActionProviderTemplateSelector, (o, args) => RefreshValue(o, AttachedMembers.MenuItem.ActionProvider)));
 }
예제 #18
0
 public static void RegisterMenuItemActionViewMembers()
 {
     MemberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.MenuItem.ActionView, (info, item) => item.GetActionView(), MenuItemUpdateActionView));
     MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.MenuItem.ActionViewTemplateSelector, (o, args) => RefreshValue(o, AttachedMembers.MenuItem.ActionView)));
     MemberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.MenuItem.IsActionViewExpanded, (info, item) => item.GetIsActionViewExpanded(), SetIsActionViewExpanded, ObserveIsActionViewExpanded, (item, args) => item.SetOnActionExpandListener(new ActionViewExpandedListener(item))));
 }
예제 #19
0
        private static void RegisterActionBarMembers(IBindingMemberProvider memberProvider)
        {
            //PopupMenu
#if !APPCOMPAT
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.PopupMenuTemplate));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.PopupMenuPlacementTargetPath));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.PopupMenuPresenter));
#endif
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.PopupMenuEvent, PopupMenuEventChanged));

            //Menu
            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.MenuItem.ActionView, (info, item) => item.GetActionView(), MenuItemUpdateActionView));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.MenuItem.ActionViewTemplateSelector, (o, args) => RefreshValue(o, AttachedMembers.MenuItem.ActionView)));
            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.MenuItem.ActionProvider, (info, item) => item.GetActionProvider(), MenuItemUpdateActionProvider));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.MenuItem.ActionProviderTemplateSelector, (o, args) => RefreshValue(o, AttachedMembers.MenuItem.ActionProvider)));


            memberProvider.Register(AttachedBindingMember
                                    .CreateMember(AttachedMembers.MenuItem.IsActionViewExpanded, (info, item) => item.GetIsActionViewExpanded(),
                                                  SetIsActionViewExpanded, ObserveIsActionViewExpanded, (item, args) => item.SetOnActionExpandListener(new ActionViewExpandedListener(item))));
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.MenuItem.ShowAsAction, null, (info, o, value) => o.SetShowAsActionFlags(value)));

            //ActionBar
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.Content.Override <ActionBar.Tab>()));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.ItemsSource.Override <ActionBar>(), (bar, args) => ActionBarUpdateItemsSource(bar)));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.SelectedItem.Override <ActionBar>(), ActionBarSelectedItemChanged));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.ContextActionBarVisible.Override <ActionBar>(), ActionBarContextActionBarVisibleChanged));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.ContextActionBarTemplate.Override <ActionBar>()));
            memberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, object>(AttachedMemberConstants.ParentExplicit, (info, bar) => bar.ThemedContext.GetActivity(), null));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.BackgroundDrawable.Override <ActionBar>(),
                                                        (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetBackgroundDrawable(
                        actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue));
                }
                else
                {
                    actionBar.SetBackgroundDrawable((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.CustomView.Override <ActionBar>(),
                                                            (info, actionBar) => actionBar.CustomView,
                                                            (info, actionBar, value) =>
            {
                if (actionBar.CustomView != null)
                {
                    ParentObserver.GetOrAdd(actionBar.CustomView).Parent = null;
                }
                if (value is int)
                {
                    value = actionBar.ThemedContext.GetBindableLayoutInflater().Inflate((int)value, null);
                }
                actionBar.CustomView = (View)value;
                if (actionBar.CustomView != null)
                {
                    ParentObserver.GetOrAdd(actionBar.CustomView).Parent = actionBar;
                }
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayHomeAsUpEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayHomeAsUpEnabled(args.NewValue)));

            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.DisplayOptions.Override <ActionBar>().Cast <ActionBarDisplayOptions>(),
                                                            (info, actionBar) => actionBar.GetActionBarDisplayOptions(),
                                                            (info, actionBar, value) =>
            {
                actionBar.SetActionBarDisplayOptions(value);
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayShowCustomEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayShowCustomEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayShowHomeEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayShowHomeEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayShowTitleEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayShowTitleEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayUseLogoEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayUseLogoEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.HomeButtonEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetHomeButtonEnabled(args.NewValue)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.Icon.Override <ActionBar>(), (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetIcon((int)args.NewValue);
                }
                else
                {
                    actionBar.SetIcon((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.Logo.Override <ActionBar>(), (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetLogo((int)args.NewValue);
                }
                else
                {
                    actionBar.SetLogo((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.NavigationMode.Override <ActionBar>().Cast <ActionBarNavigationMode>(),
                                                            (info, actionBar) => actionBar.GetNavigationMode(), ActionBarSetNavigationMode));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.SplitBackgroundDrawable.Override <ActionBar>(),
                                                        (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetSplitBackgroundDrawable(
                        actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue));
                }
                else
                {
                    actionBar.SetSplitBackgroundDrawable((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.StackedBackgroundDrawable.Override <ActionBar>(),
                                                        (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetStackedBackgroundDrawable(
                        actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue));
                }
                else
                {
                    actionBar.SetStackedBackgroundDrawable((Drawable)args.NewValue);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.IsShowing.Override <ActionBar>(), (info, actionBar) => actionBar.IsShowing, SetActionBarIsShowing));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar, string>("Subtitle",
                                                                                (info, actionBar) => actionBar.Subtitle, (info, actionBar, value) =>
            {
                actionBar.Subtitle = value;
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar, string>("Title",
                                                                                (info, actionBar) => actionBar.Title, (info, actionBar, value) =>
            {
                actionBar.Title = value;
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.Visible.Override <ActionBar>(), (info, actionBar) => actionBar.IsShowing, SetActionBarIsShowing));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.DropDownItemTemplate.Override <ActionBar>()));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.DropDownItemTemplateSelector.Override <ActionBar>()));

            //ActionBar.Tab
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.ContentTemplateSelector.Override <ActionBar.Tab>()));
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.ContentTemplate.Override <ActionBar.Tab>()));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar.Tab, string>("ContentDescription",
                                                                                    (info, tab) => tab.ContentDescription,
                                                                                    (info, tab, value) =>
            {
                tab.SetContentDescription(value);
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBarTab.CustomView.Override <ActionBar.Tab>(),
                                                            (info, tab) => tab.CustomView, (info, tab, value) =>
            {
                if (tab.CustomView != null)
                {
                    ParentObserver.GetOrAdd(tab.CustomView).Parent = null;
                }
                if (value is int)
                {
                    value = GetContextFromItem(tab).GetBindableLayoutInflater().Inflate((int)value, null);
                }
                tab.SetCustomView((View)value);
                if (tab.CustomView != null)
                {
                    ParentObserver.GetOrAdd(tab.CustomView).Parent = tab;
                }
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBarTab.Icon.Override <ActionBar.Tab>(),
                                                            (info, tab) => tab.Icon, (info, tab, value) =>
            {
                if (value is int)
                {
                    tab.SetIcon((int)value);
                }
                else
                {
                    tab.SetIcon((Drawable)value);
                }
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar.Tab, string>("Text",
                                                                                    (info, tab) => tab.Text,
                                                                                    (info, tab, value) =>
            {
                tab.SetText(value);
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember <ActionBar.Tab, Object>("Tag",
                                                                                    (info, tab) => tab.Tag,
                                                                                    (info, tab, value) =>
            {
                tab.SetTag(value);
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember.CreateMember <ActionBar, HomeButtonImpl>("HomeButton",
                                                                                                   (info, bar) => HomeButtonImpl.GetOrAdd(bar), null));
            memberProvider.Register(AttachedBindingMember.CreateEvent <HomeButtonImpl>("Click",
                                                                                       (info, homeButton, arg3) => homeButton.AddWithUnsubscriber(arg3)));

            //SearchView
            BindingBuilderExtensions.RegisterDefaultBindingMember <SearchView>(() => v => v.Query);
            var queryMember = AttachedBindingMember.CreateMember <SearchView, string>("Query",
                                                                                      (info, searchView) => searchView.Query,
                                                                                      (info, searchView, value) => searchView.SetQuery(value, false), "QueryTextChange");
            memberProvider.Register(queryMember);
            memberProvider.Register("Text", queryMember);
        }
예제 #20
0
        protected override bool LoadInternal()
        {
            IBindingMemberProvider provider = BindingServiceProvider.MemberProvider;

            //NavigationView
            provider.Register(
                AttachedBindingMember.CreateAutoProperty(AttachedMembersDesign.NavigationView.MenuTemplate,
                                                         NavigationViewMenuTemplateChanged));

            //TabLayout
            provider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ViewGroup.ItemsSource.Override <TabLayout>(), TabLayoutItemsSourceChanged));
            provider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersDesign.TabLayout.RestoreSelectedIndex));
            provider.Register(AttachedBindingMember.CreateMember(AttachedMembersDesign.TabLayout.SelectedItem,
                                                                 TabLayoutGetSelectedItem, TabLayoutSetSelectedItem, (info, layout, arg3) =>
            {
                arg3 = arg3.ToWeakEventListener();
                layout.TabSelected   += arg3.Handle;
                layout.TabUnselected += arg3.Handle;
                return(WeakActionToken.Create(layout, arg3, (tabLayout, listener) =>
                {
                    tabLayout.TabSelected -= listener.Handle;
                    tabLayout.TabUnselected -= listener.Handle;
                }));
            }));

            //TabLayout.Tab
            provider.Register(AttachedBindingMember.CreateNotifiableMember <TabLayout.Tab, string>("Text",
                                                                                                   (info, tab) => tab.Text,
                                                                                                   (info, tab, arg3) =>
            {
                tab.SetText(arg3);
                return(true);
            }));
            provider.Register(AttachedBindingMember.CreateNotifiableMember <TabLayout.Tab, string>("ContentDescription",
                                                                                                   (info, tab) => tab.ContentDescription,
                                                                                                   (info, tab, arg3) =>
            {
                tab.SetContentDescription(arg3);
                return(true);
            }));
            provider.Register(AttachedBindingMember.CreateNotifiableMember <TabLayout.Tab, object>("Icon",
                                                                                                   (info, tab) => tab.Icon,
                                                                                                   (info, tab, arg3) =>
            {
                if (arg3 is int)
                {
                    tab.SetIcon((int)arg3);
                }
                else
                {
                    tab.SetIcon((Drawable)arg3);
                }
                return(true);
            }));
            provider.Register(AttachedBindingMember.CreateNotifiableMember <TabLayout.Tab, Object>("Tag",
                                                                                                   (info, tab) => tab.Tag,
                                                                                                   (info, tab, arg3) =>
            {
                tab.SetTag(arg3);
                return(true);
            }));

            //EditText
            provider.Register(AttachedBindingMember.CreateAutoProperty <EditText, string>(BindingErrorProvider.ErrorPropertyName,
                                                                                          (text, args) =>
            {
                var layout = text.Parent as TextInputLayout;
                if (layout == null)
                {
                    text.Error = args.NewValue;
                }
                else
                {
                    text.Error   = null;
                    layout.Error = args.NewValue;
                }
            }, getDefaultValue: (text, info) => text.Error));

            //Activity
            provider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersDesign.Activity.SnackbarView));
            provider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersDesign.Activity.SnackbarViewSelector));
            provider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersDesign.Activity.SnackbarTemplateSelector));

            if (IocContainer != null)
            {
                IToastPresenter toastPresenter;
                IocContainer.TryGet(out toastPresenter);
                IocContainer.BindToConstant <IToastPresenter>(new SnackbarToastPresenter(IocContainer.Get <IThreadManager>(), toastPresenter));
            }

            return(true);
        }
예제 #21
0
 public static void RegisterActionBarTabMembers()
 {
     MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.Content.Override <ActionBar.Tab>()));
     MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.ContentTemplateSelector.Override <ActionBar.Tab>()));
     MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBarTab.ContentTemplate.Override <ActionBar.Tab>()));
     MemberProvider.Register(AttachedBindingMember
                             .CreateNotifiableMember <ActionBar.Tab, string>(nameof(ActionBar.Tab.ContentDescription),
                                                                             (info, tab) => tab.ContentDescription,
                                                                             (info, tab, value) =>
     {
         tab.SetContentDescription(value);
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember
                             .CreateNotifiableMember(AttachedMembers.ActionBarTab.CustomView.Override <ActionBar.Tab>(),
                                                     (info, tab) => tab.CustomView, (info, tab, value) =>
     {
         if (tab.CustomView != null)
         {
             ParentObserver.GetOrAdd(tab.CustomView).Parent = null;
         }
         if (value is int)
         {
             value = GetContextFromItem(tab).GetBindableLayoutInflater().Inflate((int)value, null);
         }
         tab.SetCustomView((View)value);
         if (tab.CustomView != null)
         {
             ParentObserver.GetOrAdd(tab.CustomView).Parent = tab;
         }
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember
                             .CreateNotifiableMember(AttachedMembers.ActionBarTab.Icon.Override <ActionBar.Tab>(),
                                                     (info, tab) => tab.Icon, (info, tab, value) =>
     {
         if (value is int)
         {
             tab.SetIcon((int)value);
         }
         else
         {
             tab.SetIcon((Drawable)value);
         }
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember
                             .CreateNotifiableMember <ActionBar.Tab, string>(nameof(ActionBar.Tab.Text),
                                                                             (info, tab) => tab.Text,
                                                                             (info, tab, value) =>
     {
         tab.SetText(value);
         return(true);
     }));
     MemberProvider.Register(AttachedBindingMember
                             .CreateNotifiableMember <ActionBar.Tab, Object>(nameof(ActionBar.Tab.Tag),
                                                                             (info, tab) => tab.Tag,
                                                                             (info, tab, value) =>
     {
         tab.SetTag(value);
         return(true);
     }));
 }
예제 #22
0
        public static void RegisterActionBarMembers()
        {
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.ItemsSource.Override <ActionBar>(), (bar, args) => ActionBarUpdateItemsSource(bar)));
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.SelectedItem.Override <ActionBar>(), ActionBarSelectedItemChanged));
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.ContextActionBarVisible.Override <ActionBar>(), ActionBarContextActionBarVisibleChanged));
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.ContextActionBarTemplate.Override <ActionBar>()));

            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.BackgroundDrawable.Override <ActionBar>(),
                                                        (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetBackgroundDrawable(
                        actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue));
                }
                else
                {
                    actionBar.SetBackgroundDrawable((Drawable)args.NewValue);
                }
            }));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.CustomView.Override <ActionBar>(),
                                                            (info, actionBar) => actionBar.CustomView,
                                                            (info, actionBar, value) =>
            {
                if (actionBar.CustomView != null)
                {
                    ParentObserver.GetOrAdd(actionBar.CustomView).Parent = null;
                }
                if (value is int)
                {
                    value = actionBar.ThemedContext.GetBindableLayoutInflater().Inflate((int)value, null);
                }
                actionBar.CustomView = (View)value;
                if (actionBar.CustomView != null)
                {
                    ParentObserver.GetOrAdd(actionBar.CustomView).Parent = actionBar;
                }
                return(true);
            }));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayHomeAsUpEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayHomeAsUpEnabled(args.NewValue)));

            MemberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.DisplayOptions.Override <ActionBar>().Cast <ActionBarDisplayOptions>(),
                                                            (info, actionBar) => actionBar.GetActionBarDisplayOptions(),
                                                            (info, actionBar, value) =>
            {
                actionBar.SetActionBarDisplayOptions(value);
                return(true);
            }));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayShowCustomEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayShowCustomEnabled(args.NewValue)));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayShowHomeEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayShowHomeEnabled(args.NewValue)));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayShowTitleEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayShowTitleEnabled(args.NewValue)));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.DisplayUseLogoEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetDisplayUseLogoEnabled(args.NewValue)));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.HomeButtonEnabled.Override <ActionBar>(),
                                                        (actionBar, args) => actionBar.SetHomeButtonEnabled(args.NewValue)));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.Icon.Override <ActionBar>(), (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetIcon((int)args.NewValue);
                }
                else
                {
                    actionBar.SetIcon((Drawable)args.NewValue);
                }
            }));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.Logo.Override <ActionBar>(), (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetLogo((int)args.NewValue);
                }
                else
                {
                    actionBar.SetLogo((Drawable)args.NewValue);
                }
            }));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.NavigationMode.Override <ActionBar>().Cast <ActionBarNavigationMode>(),
                                                            (info, actionBar) => actionBar.GetNavigationMode(), ActionBarSetNavigationMode));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.SplitBackgroundDrawable.Override <ActionBar>(),
                                                        (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetSplitBackgroundDrawable(
                        actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue));
                }
                else
                {
                    actionBar.SetSplitBackgroundDrawable((Drawable)args.NewValue);
                }
            }));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateAutoProperty(AttachedMembers.ActionBar.StackedBackgroundDrawable.Override <ActionBar>(),
                                                        (actionBar, args) =>
            {
                if (args.NewValue is int)
                {
                    actionBar.SetStackedBackgroundDrawable(
                        actionBar.ThemedContext.Resources.GetDrawable((int)args.NewValue));
                }
                else
                {
                    actionBar.SetStackedBackgroundDrawable((Drawable)args.NewValue);
                }
            }));
            MemberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.IsShowing.Override <ActionBar>(), (info, actionBar) => actionBar.IsShowing, SetActionBarIsShowing));


            MemberProvider.Register(AttachedBindingMember
                                    .CreateNotifiableMember(AttachedMembers.ActionBar.Visible.Override <ActionBar>(), (info, actionBar) => actionBar.IsShowing, SetActionBarIsShowing));
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.DropDownItemTemplate.Override <ActionBar>()));
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ActionBar.DropDownItemTemplateSelector.Override <ActionBar>()));
        }
        static PlatformDataBindingModule()
        {
            SelecectedControllerChangedHandler = TabBarOnViewControllerSelected;

            //Object
            ItemsSourceMember           = AttachedBindingMember.CreateAutoProperty <object, IEnumerable>(AttachedMemberConstants.ItemsSource, ObjectItemsSourceChanged);
            CollectionViewManagerMember = AttachedBindingMember.CreateAutoProperty <object, ICollectionViewManager>("CollectionViewManager");
            ContentViewManagerMember    = AttachedBindingMember.CreateAutoProperty <object, IContentViewManager>("ContentViewManager");

            //UIView
            ContentMember         = AttachedBindingMember.CreateAutoProperty <UIView, object>(AttachedMemberConstants.Content, ContentChanged);
            ContentTemplateMember = AttachedBindingMember.CreateAutoProperty <UIView, IDataTemplateSelector>(AttachedMemberConstants.ContentTemplate, ContentTemplateChanged);

            //UITableView
            TableViewSelectedItemChangedEvent = AttachedBindingMember.CreateEvent <UITableView>("SelectedItemChanged");

            TableViewReadOnlyMember         = AttachedBindingMember.CreateAutoProperty <UITableView, bool>("ReadOnly");
            TableViewUseAnimationsMember    = AttachedBindingMember.CreateAutoProperty <UITableView, bool?>("UseAnimations");
            TableViewCellBindMember         = AttachedBindingMember.CreateAutoProperty <UITableView, Action <UITableViewCell> >("CellBind");
            TableViewAddAnimationMember     = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewRowAnimation?>("AddAnimation");
            TableViewRemoveAnimationMember  = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewRowAnimation?>("RemoveAnimation");
            TableViewReplaceAnimationMember = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewRowAnimation?>("ReplaceAnimation");
            TableViewScrollPositionMember   = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewScrollPosition?>("ScrollPosition");
            TableViewDefaultCellStyleMember = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewCellStyle?>("CellStyle");

            //UITableViewCell
            TableViewCellAccessoryButtonTappedEvent = AttachedBindingMember.CreateEvent <UITableViewCell>("AccessoryButtonTapped");
            TableViewCellDeleteClickEvent           = AttachedBindingMember.CreateEvent <UITableViewCell>("DeleteClick");
            TableViewCellInsertClickEvent           = AttachedBindingMember.CreateEvent <UITableViewCell>("InsertClick");
            TableViewCellMoveableMember             = AttachedBindingMember.CreateAutoProperty <UITableViewCell, bool?>("Moveable");
            TitleForDeleteConfirmationMember        = AttachedBindingMember.CreateAutoProperty <UITableViewCell, string>("TitleForDeleteConfirmation");
            TableViewCellEditingStyleMember         = AttachedBindingMember.CreateAutoProperty <UITableViewCell, UITableViewCellEditingStyle?>("EditingStyle");
            TableViewCellShouldHighlightMember      = AttachedBindingMember.CreateAutoProperty <UITableViewCell, bool?>("ShouldHighlight");

            TableViewCellSelectedMember = AttachedBindingMember.CreateNotifiableMember <UITableViewCell, bool>(
                "Selected", (info, cell) =>
            {
                var cellBindable = cell as UITableViewCellBindable;
                if (cellBindable == null)
                {
                    return(cell.Selected);
                }
                return(cellBindable.SelectedBind);
            }, (info, cell, arg3) =>
            {
                var cellBindable = cell as UITableViewCellBindable;
                if (cellBindable == null)
                {
                    cell.Selected = arg3;
                }
                else
                {
                    cellBindable.SelectedBind = arg3;
                }
                return(true);
            });
            TableViewCellHighlightedMember = AttachedBindingMember.CreateNotifiableMember <UITableViewCell, bool>(
                "Highlighted", (info, cell) => cell.Highlighted,
                (info, cell, arg3) =>
            {
                if (cell.Highlighted == arg3)
                {
                    return(false);
                }
                cell.Highlighted = arg3;
                return(true);
            });
            TableViewCellEditingMember = AttachedBindingMember.CreateNotifiableMember <UITableViewCell, bool>(
                "Editing", (info, cell) => cell.Editing,
                (info, cell, arg3) =>
            {
                if (cell.Editing == arg3)
                {
                    return(false);
                }
                cell.Editing = arg3;
                return(true);
            });

            //UICollectionView
            CollectionViewUseAnimationsMember      = AttachedBindingMember.CreateAutoProperty <UICollectionView, bool?>("UseAnimations");
            CollectionViewScrollPositionMember     = AttachedBindingMember.CreateAutoProperty <UICollectionView, UICollectionViewScrollPosition?>("ScrollPosition");
            CollectionViewSelectedItemChangedEvent = AttachedBindingMember.CreateEvent <UICollectionView>("SelectedItemChanged");

            //UICollectionViewCell
            CollectionViewCellShouldSelectMember    = AttachedBindingMember.CreateAutoProperty <UICollectionViewCell, bool?>("ShouldSelect");
            CollectionViewCellShouldDeselectMember  = AttachedBindingMember.CreateAutoProperty <UICollectionViewCell, bool?>("ShouldDeselect");
            CollectionViewCellShouldHighlightMember = AttachedBindingMember.CreateAutoProperty <UICollectionViewCell, bool?>("ShouldHighlight");

            CollectionViewCellSelectedMember = AttachedBindingMember
                                               .CreateNotifiableMember <UICollectionViewCell, bool>("Selected", (info, cell) => cell.Selected,
                                                                                                    (info, cell, arg3) =>
            {
                var cellBindable = cell as UICollectionViewCellBindable;
                if (cellBindable == null)
                {
                    cell.Selected = arg3;
                }
                else
                {
                    cellBindable.SelectedBind = arg3;
                }
                return(true);
            });
            CollectionViewCellHighlightedMember = AttachedBindingMember
                                                  .CreateNotifiableMember <UICollectionViewCell, bool>("Highlighted", (info, cell) => cell.Highlighted,
                                                                                                       (info, cell, arg3) =>
            {
                cell.Highlighted = arg3;
                return(true);
            });

            //UITabBarController
            TabBarSelectedItemMember = AttachedBindingMember.CreateAutoProperty <UITabBarController, object>(AttachedMemberConstants.SelectedItem, TabBarSelectedItemChanged, TabBarSelectedItemAttached);
        }
        private static void RegisterMenuMembers(IBindingMemberProvider memberProvider)
        {
            //IMenu
            memberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.Menu.ItemsSource, MenuItemsSourceChanged));
            var menuEnabledMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.Menu.Enabled,
                                                                             (menu, args) => menu.SetGroupEnabled(0, args.NewValue.GetValueOrDefault()));

            memberProvider.Register(menuEnabledMember);
            memberProvider.Register("IsEnabled", menuEnabledMember);

            var menuVisibleMember = AttachedBindingMember.CreateAutoProperty(AttachedMembers.Menu.Visible,
                                                                             (menu, args) => menu.SetGroupVisible(0, args.NewValue.GetValueOrDefault()));

            memberProvider.Register(menuVisibleMember);
            memberProvider.Register("IsVisible", menuVisibleMember);

            //IMenuItem
            BindingBuilderExtensions.RegisterDefaultBindingMember(AttachedMembers.MenuItem.Click);
            memberProvider.Register(AttachedBindingMember.CreateNotifiableMember(AttachedMembers.MenuItem.IsChecked,
                                                                                 (info, item) => item.IsChecked, (info, item, value) =>
            {
                if (value == item.IsChecked)
                {
                    return(false);
                }
                item.SetChecked(value);
                return(true);
            }));
            memberProvider.Register(AttachedBindingMember.CreateEvent(AttachedMembers.MenuItem.Click, SetClickEventValue,
                                                                      (item, args) => item.SetOnMenuItemClickListener(new MenuItemOnMenuItemClickListener(item))));

            memberProvider.Register(AttachedBindingMember
                                    .CreateMember <IMenuItem, object>("AlphabeticShortcut",
                                                                      (info, item) => item.AlphabeticShortcut,
                                                                      (info, item, value) =>
            {
                if (value is char)
                {
                    item.SetAlphabeticShortcut((char)value);
                }
                else
                {
                    item.SetAlphabeticShortcut(value.ToStringSafe()[0]);
                }
            }));
            memberProvider.Register(AttachedBindingMember
                                    .CreateMember(AttachedMembers.MenuItem.Icon, (info, item) => item.Icon,
                                                  (info, item, value) =>
            {
                if (value is int)
                {
                    item.SetIcon((int)value);
                }
                else
                {
                    item.SetIcon((Drawable)value);
                }
            }));

            memberProvider.Register(AttachedBindingMember
                                    .CreateMember <IMenuItem, bool>("IsCheckable",
                                                                    (info, item) => item.IsCheckable,
                                                                    (info, item, value) => item.SetCheckable(value)));

            var menuItemEnabled = AttachedBindingMember.CreateMember <IMenuItem, bool>(AttachedMemberConstants.Enabled,
                                                                                       (info, item) => item.IsEnabled,
                                                                                       (info, item, value) => item.SetEnabled(value));

            memberProvider.Register(menuItemEnabled);
            memberProvider.Register("IsEnabled", menuItemEnabled);
            memberProvider.Register(AttachedBindingMember
                                    .CreateMember <IMenuItem, bool>("IsVisible", (info, item) => item.IsVisible,
                                                                    (info, item, value) => item.SetVisible(value)));
            memberProvider.Register(AttachedBindingMember
                                    .CreateMember <IMenuItem, object>("NumericShortcut",
                                                                      (info, item) => item.NumericShortcut,
                                                                      (info, item, value) =>
            {
                if (value is char)
                {
                    item.SetNumericShortcut((char)value);
                }
                else
                {
                    item.SetNumericShortcut(value.ToStringSafe()[0]);
                }
            }));
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.MenuItem.Title,
                                                                       (info, item) => item.TitleFormatted.ToStringSafe(),
                                                                       (info, item, value) => item.SetTitle(value)));
            memberProvider.Register(AttachedBindingMember.CreateMember(AttachedMembers.MenuItem.TitleCondensed,
                                                                       (info, item) => item.TitleCondensedFormatted.ToStringSafe(),
                                                                       (info, item, value) => item.SetTitleCondensed(value)));
        }