예제 #1
0
        private static void ActionBarUpdateItemsSource(ActionBar actionBar)
        {
            switch (actionBar.GetNavigationMode())
            {
            case ActionBarNavigationMode.List:
#if APPCOMPAT
                IItemsSourceAdapter sourceAdapter = actionBar.GetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSourceAdapter);
#else
                IItemsSourceAdapter sourceAdapter = actionBar.GetBindingMemberValue(AttachedMembers.ActionBar.ItemsSourceAdapter);
#endif
                if (sourceAdapter == null)
                {
                    sourceAdapter = AndroidToolkitExtensions.ItemsSourceAdapterFactory(actionBar, actionBar.ThemedContext, DataContext.Empty);
#if APPCOMPAT
                    actionBar.SetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSourceAdapter, sourceAdapter);
#else
                    actionBar.SetBindingMemberValue(AttachedMembers.ActionBar.ItemsSourceAdapter, sourceAdapter);
#endif
                    actionBar.SetListNavigationCallbacks(sourceAdapter, new ActionBarNavigationListener(actionBar));
                }
#if APPCOMPAT
                sourceAdapter.ItemsSource = actionBar.GetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSource);
#else
                sourceAdapter.ItemsSource = actionBar.GetBindingMemberValue(AttachedMembers.ActionBar.ItemsSource);
#endif
                break;

            case ActionBarNavigationMode.Standard:
#if APPCOMPAT
                actionBar.SetBindingMemberValue(AttachedMembersCompat.ActionBar.SelectedItem, BindingExtensions.NullValue);
#else
                actionBar.SetBindingMemberValue(AttachedMembers.ActionBar.SelectedItem, BindingExtensions.NullValue);
#endif

                actionBar.SetListNavigationCallbacks(null, null);
#if APPCOMPAT
                actionBar.GetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSourceGenerator)?.SetItemsSource(null);
                var adapter = actionBar.GetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSourceAdapter);
#else
                actionBar.GetBindingMemberValue(AttachedMembers.ActionBar.ItemsSourceGenerator)?.SetItemsSource(null);
                var adapter = actionBar.GetBindingMemberValue(AttachedMembers.ActionBar.ItemsSourceAdapter);
#endif
                if (adapter != null)
                {
                    adapter.ItemsSource = null;
                }
                break;

            case ActionBarNavigationMode.Tabs:
#if APPCOMPAT
                actionBar.GetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSourceGenerator)?.SetItemsSource(actionBar.GetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSource));
#else
                actionBar.GetBindingMemberValue(AttachedMembers.ActionBar.ItemsSourceGenerator)?.SetItemsSource(actionBar.GetBindingMemberValue(AttachedMembers.ActionBar.ItemsSource));
#endif

                break;
            }
        }
예제 #2
0
 internal ViewGroupItemsSourceGenerator([NotNull] ViewGroup viewGroup)
 {
     Should.NotBeNull(viewGroup, nameof(viewGroup));
     _viewGroup = viewGroup;
     _adapter   = AndroidToolkitExtensions.ItemsSourceAdapterFactory(viewGroup, viewGroup.Context, Context);
     _collectionViewManagerMember = BindingServiceProvider
                                    .MemberProvider
                                    .GetBindingMember(viewGroup.GetType(), AttachedMembers.ViewGroup.CollectionViewManager, false, false);
     TryListenActivity(viewGroup.Context);
 }