public void OnAttached(Activity activity) { var actionBar = activity.GetActionBar(); if (actionBar == null) { Tracer.Error("Cannot apply ActionBarView the ActionBar is null, activity {0}", activity.GetType().FullName); return; } var activityView = activity as IActivityView; if (activityView != null) activityView.Mediator.Destroyed += DestroyedHandler; if (_resourceId != int.MinValue) { if (_tabContentId != int.MinValue) ServiceProvider.AttachedValueProvider.SetValue(actionBar, TabContentIdKey, _tabContentId); using (XmlReader reader = Context.Resources.GetLayout(_resourceId)) { //NOTE XDocument throws an error. var document = new XmlDocument(); document.Load(reader); using (var stringReader = new StringReader(PlatformExtensions.XmlTagsToUpper(document.InnerXml))) { var barTemplate = (ActionBarTemplate)Serializer.Deserialize(stringReader); barTemplate.Apply(activity); } } } if (_bindings == null) return; for (int i = 0; i < _bindings.Count; i++) BindingServiceProvider.BindingProvider.CreateBindingsFromString(actionBar, _bindings[i], null); this.RemoveFromParent(); this.ClearBindingsRecursively(true, true); }
public static void Clear(Activity activity) { var actionBar = activity.GetActionBar(false); if (actionBar == null) return; for (int i = 0; i < actionBar.TabCount; i++) ActionBarTabTemplate.ClearTab(actionBar, actionBar.GetTabAt(i), false); actionBar.ClearBindings(true, true); }
private static void ActivityViewOnSaveInstanceState(Activity sender, ValueEventArgs<Bundle> args) { var actionBar = sender.GetActionBar(); if (actionBar == null) return; var index = actionBar.SelectedNavigationIndex; args.Value.PutInt(SelectedTabIndexKey, index); }
public void Apply(Activity activity) { PlatformExtensions.ValidateTemplate(ItemsSource, Tabs); var actionBar = activity.GetActionBar(); var setter = new XmlPropertySetter<ActionBarTemplate, ActionBar>(actionBar, activity, new BindingSet()); setter.SetEnumProperty<ActionBarNavigationMode>(() => template => template.NavigationMode, NavigationMode); setter.SetProperty(() => template => template.DataContext, DataContext); if (!string.IsNullOrEmpty(Bind)) setter.BindingSet.BindFromExpression(actionBar, Bind); setter.SetProperty(() => template => template.ContextActionBarTemplate, ContextActionBarTemplate); setter.SetBinding(() => template => template.ContextActionBarVisible, ContextActionBarVisible, false); setter.SetProperty(() => template => template.BackgroundDrawable, BackgroundDrawable); setter.SetProperty(() => template => template.CustomView, CustomView); setter.SetEnumProperty<ActionBarDisplayOptions>(() => template => template.DisplayOptions, DisplayOptions); setter.SetBoolProperty(() => template => template.DisplayHomeAsUpEnabled, DisplayHomeAsUpEnabled); setter.SetBoolProperty(() => template => template.DisplayShowCustomEnabled, DisplayShowCustomEnabled); setter.SetBoolProperty(() => template => template.DisplayShowHomeEnabled, DisplayShowHomeEnabled); setter.SetBoolProperty(() => template => template.DisplayShowTitleEnabled, DisplayShowTitleEnabled); setter.SetBoolProperty(() => template => template.DisplayUseLogoEnabled, DisplayUseLogoEnabled); setter.SetBoolProperty(() => template => template.HomeButtonEnabled, HomeButtonEnabled); setter.SetProperty(() => template => template.Icon, Icon); setter.SetProperty(() => template => template.Logo, Logo); setter.SetProperty(() => template => template.SplitBackgroundDrawable, SplitBackgroundDrawable); setter.SetProperty(() => template => template.StackedBackgroundDrawable, StackedBackgroundDrawable); setter.SetBoolProperty(() => template => template.IsShowing, IsShowing); setter.SetStringProperty(() => template => template.Subtitle, Subtitle); setter.SetStringProperty(() => template => template.Title, Title); setter.SetBoolProperty(() => template => template.Visible, Visible); setter.SetBinding("HomeButton.Click", HomeButtonClick, false); if (string.IsNullOrEmpty(ItemsSource)) { if (Tabs != null) { ActionBar.Tab firstTab = null; for (int index = 0; index < Tabs.Count; index++) { var tab = Tabs[index].CreateTab(actionBar); if (firstTab == null) firstTab = tab; actionBar.AddTab(tab); } TryRestoreSelectedIndex(activity, actionBar); } } else { #if APPCOMPAT actionBar.SetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSourceGenerator, new ActionBarTabItemsSourceGenerator(actionBar, TabTemplate)); #else actionBar.SetBindingMemberValue(AttachedMembers.ActionBar.ItemsSourceGenerator, new ActionBarTabItemsSourceGenerator(actionBar, TabTemplate)); #endif setter.SetBinding(() => template => template.ItemsSource, ItemsSource, false); } setter.SetBinding(() => template => template.SelectedItem, SelectedItem, false); setter.Apply(); }