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);
        }
示例#2
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)));
 }