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 = ItemsSourceAdapter.Factory(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;
            }
        }
Esempio n. 2
0
        private static void AutoCompleteTextViewItemsSourceChanged(AutoCompleteTextView sender, AttachedMemberChangedEventArgs <IEnumerable> args)
        {
            var listAdapter = sender.Adapter as IItemsSourceAdapter;

            if (listAdapter == null)
            {
                listAdapter    = ItemsSourceAdapter.Factory(sender, sender.Context, DataContext.Empty);
                sender.Adapter = listAdapter;
            }
            listAdapter.ItemsSource = args.NewValue;
        }
        private static void ActionBarUpdateItemsSource(ActionBar actionBar)
        {
            switch (actionBar.GetNavigationMode())
            {
            case ActionBarNavigationMode.List:
                IItemsSourceAdapter sourceAdapter = ItemsSourceAdapter.Get(actionBar);
                if (sourceAdapter == null)
                {
                    sourceAdapter = ItemsSourceAdapter.Factory(actionBar, actionBar.ThemedContext, DataContext.Empty);
                    ItemsSourceAdapter.Set(actionBar, sourceAdapter);
                    actionBar.SetListNavigationCallbacks(sourceAdapter, new ActionBarNavigationListener(actionBar));
                }
                sourceAdapter.ItemsSource = ActionBarItemsSourceMember.GetValue(actionBar, null);
                break;

            case ActionBarNavigationMode.Standard:
                ActionBarSelectedItemMember.SetValue(actionBar, BindingExtensions.NullValue);
                actionBar.SetListNavigationCallbacks(null, null);
                var generator = ItemsSourceGeneratorBase.Get(actionBar);
                if (generator != null)
                {
                    generator.SetItemsSource(null);
                }
                var adapter = ItemsSourceAdapter.Get(actionBar);
                if (adapter != null)
                {
                    adapter.ItemsSource = null;
                }
                break;

            case ActionBarNavigationMode.Tabs:
                var tabGenerator = ItemsSourceGeneratorBase.Get(actionBar);
                if (tabGenerator != null)
                {
                    tabGenerator.SetItemsSource(ActionBarItemsSourceMember.GetValue(actionBar, null));
                }
                break;
            }
        }
Esempio n. 4
0
        private static void ViewGroupItemsSourceChanged(ViewGroup sender, AttachedMemberChangedEventArgs <IEnumerable> args)
        {
            var container = sender as AdapterView;

            if (container == null)
            {
                var sourceGenerator = ViewGroupItemsSourceGenerator.GetOrAdd(sender);
                if (sourceGenerator != null)
                {
                    sourceGenerator.SetItemsSource(args.NewValue);
                }
                return;
            }
            var adapter = GetAdapter(container) as IItemsSourceAdapter;

            if (adapter == null)
            {
                adapter = ItemsSourceAdapter.Factory(container, container.Context, DataContext.Empty);
                SetAdapter(container, adapter);
            }
            adapter.ItemsSource = args.NewValue;
        }