public bool OnNavigationItemSelected(int itemPosition, long itemId)
            {
                var adapter = ItemsSourceAdapter.Get(_actionBar);

                if (adapter == null)
                {
                    return(false);
                }
                ActionBarSelectedItemMember.SetValue(_actionBar, adapter.GetRawItem(itemPosition));
                return(true);
            }
        private static void ActionBarSelectedItemChanged(ActionBar actionBar, AttachedMemberChangedEventArgs <object> args)
        {
            switch (actionBar.GetNavigationMode())
            {
            case ActionBarNavigationMode.List:
                var adapter = ItemsSourceAdapter.Get(actionBar);
                if (adapter == null || adapter.ItemsSource == null)
                {
                    return;
                }
                if (args.NewValue == null)
                {
                    args.Member.SetValue(actionBar, new[] { adapter.GetRawItem(actionBar.SelectedNavigationIndex) });
                }
                else
                {
                    actionBar.SetSelectedNavigationItem(adapter.GetPosition(args.NewValue));
                }
                break;

            case ActionBarNavigationMode.Tabs:
                var tabGenerator = ItemsSourceGeneratorBase.Get(actionBar) as ActionBarTabItemsSourceGenerator;
                if (tabGenerator == null)
                {
                    var tabValue = args.NewValue as ActionBar.Tab;
                    if (tabValue != null && tabValue.Position != actionBar.SelectedNavigationIndex)
                    {
                        tabValue.Select();
                    }
                }
                else
                {
                    if (args.NewValue == null)
                    {
                        object ctx = actionBar.SelectedNavigationIndex < 0 ? null : actionBar.SelectedTab;
                        if (ctx != null)
                        {
                            ctx = BindingServiceProvider.ContextManager.GetBindingContext(ctx).Value;
                        }
                        args.Member.SetValue(actionBar, new[] { ctx });
                    }
                    else
                    {
                        tabGenerator.SetSelectedItem(args.NewValue);
                    }
                }
                break;
            }
        }
        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;
            }
        }