Example #1
0
 public static void RegisterToolbarMembers()
 {
     //Toolbar
     MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.MenuTemplate.Override <Toolbar>(), ToolbarMenuTemplateChanged));
     MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersCompat.Toolbar.IsActionBar,
                                                                      ToolbarIsActionBarChanged));
 }
Example #2
0
        public static void RegisterSearchViewMembers()
        {
            BindingBuilderExtensions.RegisterDefaultBindingMember <SearchView>(nameof(SearchView.Query));
            var queryMember = AttachedBindingMember.CreateMember <SearchView, string>(nameof(SearchView.Query),
                                                                                      (info, searchView) => searchView.Query,
                                                                                      (info, searchView, value) => searchView.SetQuery(value, false), nameof(SearchView.QueryTextChange));

            MemberProvider.Register(queryMember);
            MemberProvider.Register(nameof(TextView.Text), queryMember);
        }
Example #3
0
 public static void RegisterMenuItemMembers()
 {
     MemberProvider.Register(AttachedBindingMember.CreateMember <IMenuItem, string>(AttachedMembers.MenuItem.ShowAsAction.Path, null, (info, o, value) =>
     {
         if (!string.IsNullOrEmpty(value))
         {
             o.SetShowAsActionFlags((ShowAsAction)Enum.Parse(typeof(ShowAsAction), value.Replace("|", ","), true));
         }
     }));
 }
Example #4
0
        public static void RegisterDrawerLayoutMembers()
        {
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersCompat.View.DrawerIsOpened,
                                                                             ViewDrawerIsOpenedChanged, getDefaultValue: ViewDrawerIsOpenedGetDefaultValue));
            INotifiableAttachedBindingMemberInfo <DrawerLayout, bool> actionBarDrawerToggleEnabledMember =
                AttachedBindingMember.CreateAutoProperty(AttachedMembersCompat.DrawerLayout.ActionBarDrawerToggleEnabled,
                                                         (layout, args) =>
            {
                if (!args.NewValue)
                {
                    return;
                }
                Activity activity = layout.Context.GetActivity();
                if (activity != null)
                {
                    DrawerListenerImpl
                    .GetOrAdd(layout)
                    .SetListener(activity, new ActionBarDrawerToggle(activity, layout, Resource.String.Empty, Resource.String.Empty));
                }
            });

            MemberProvider.Register(actionBarDrawerToggleEnabledMember);
            MemberProvider.Register(typeof(DrawerLayout), "ActionBarDrawerEnabled", actionBarDrawerToggleEnabledMember, true);
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersCompat.DrawerLayout.DrawerListener,
                                                                             (layout, args) =>
            {
                var listener = args.NewValue as DrawerLayout.IDrawerListener;
                if (listener == null)
                {
                    var func = args.NewValue as Func <DrawerLayout, DrawerLayout.IDrawerListener>;
                    if (func != null)
                    {
                        listener = func(layout);
                    }
                }
                if (listener == null)
                {
                    Tracer.Warn("The DrawerListener '{0}' is not supported", args.NewValue);
                }
                DrawerListenerImpl.GetOrAdd(layout).SetListener(layout.Context, listener);
            }));
        }
Example #5
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)));
 }
Example #6
0
        public static void RegisterViewPagerMembers()
        {
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersCompat.ViewPager.SelectedItem, ViewPagerSelectedItemChanged,
                                                                             (pager, args) =>
            {
                //NOTE to activate listener
                pager.GetBindingMemberValue(AttachedMembersCompat.ViewPager.CurrentItem);
            }));
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersCompat.ViewPager.GetPageTitleDelegate));
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembersCompat.ViewPager.RestoreSelectedIndex));
            var itemMember = AttachedBindingMember.CreateAutoProperty(AttachedMembersCompat.ViewPager.CurrentItem,
                                                                      ViewPagerCurrentItemChanged, AdapterViewCurrentItemAttached, (pager, info) => pager.CurrentItem);

            MemberProvider.Register(itemMember);
            MemberProvider.Register(typeof(ViewPager), "SelectedIndex", itemMember, true);
            MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.ViewGroup.ItemsSource.Override <ViewPager>(),
                                                                             (pager, args) =>
            {
                var pagerAdapter = pager.Adapter as ItemsSourcePagerAdapter;
                if (pagerAdapter == null)
                {
                    pagerAdapter  = new ItemsSourcePagerAdapter(pager);
                    pager.Adapter = pagerAdapter;
                }
                pagerAdapter.ItemsSource = args.NewValue;
                if (pagerAdapter.Count > 0)
                {
                    var value = pager.GetBindingMemberValue(AttachedMembersCompat.ViewPager.SelectedItem);
                    if (value == null)
                    {
                        pager.SetBindingMemberValue(AttachedMembersCompat.ViewPager.SelectedItem, pagerAdapter.GetRawItem(0));
                    }
                    else
                    {
                        int position = pagerAdapter.GetPosition(value);
                        pager.SetBindingMemberValue(AttachedMembersCompat.ViewPager.CurrentItem, position);
                    }
                }
            }));
        }
Example #7
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)));
 }
Example #8
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))));
 }
Example #9
0
 public static void RegisterPopupMenuMembers()
 {
     MemberProvider.Register(AttachedBindingMember.CreateAutoProperty(AttachedMembers.View.PopupMenuEvent, PopupMenuEventChanged));
 }
Example #10
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);
     }));
 }
Example #11
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>()));
        }