public void Apply(IMenu menu, Context context, object parent) { PlatformExtensions.ValidateTemplate(ItemsSource, Items); var setter = new XmlPropertySetter<IMenu>(menu, context, new BindingSet()); menu.SetBindingMemberValue(AttachedMembers.Object.Parent, parent); setter.SetBinding(nameof(DataContext), DataContext, false); setter.SetBoolProperty(nameof(IsVisible), IsVisible); setter.SetBoolProperty(nameof(IsEnabled), IsEnabled); if (!string.IsNullOrEmpty(Bind)) setter.BindingSet.BindFromExpression(menu, Bind); if (string.IsNullOrEmpty(ItemsSource)) { if (Items != null) { for (int index = 0; index < Items.Count; index++) Items[index].Apply(menu, context, index, index); } } else { menu.SetBindingMemberValue(AttachedMembers.Menu.ItemsSourceGenerator, new MenuItemsSourceGenerator(menu, context, ItemTemplate)); setter.SetBinding(nameof(ItemsSource), ItemsSource, true); } setter.Apply(); }
private ActionBar.Tab CreateTabInternal(ActionBar bar, object context, bool useContext) { ActionBar.Tab newTab = bar.NewTab(); BindingExtensions.AttachedParentMember.SetValue(newTab, bar); var setter = new XmlPropertySetter <ActionBarTabTemplate, ActionBar.Tab>(newTab, bar.ThemedContext, new BindingSet()); if (useContext) { BindingServiceProvider.ContextManager.GetBindingContext(newTab).Value = context; } else { setter.SetProperty(template => template.DataContext, DataContext); } setter.SetBinding(template => template.ContentTemplateSelector, ContentTemplateSelector, false); setter.SetProperty(template => template.ContentTemplate, ContentTemplate); setter.SetProperty(template => template.Content, Content); setter.SetStringProperty(template => template.ContentDescription, ContentDescription); setter.SetProperty(template => template.CustomView, CustomView); setter.SetProperty(template => template.Icon, Icon); setter.SetProperty(template => template.Text, Text); setter.SetProperty(template => template.Tag, Tag); setter.Apply(); var tabListener = new TabListener(new DataTemplateProvider(bar, AttachedMemberConstants.ContentTemplate, AttachedMemberConstants.ContentTemplateSelector)); ServiceProvider.AttachedValueProvider.SetValue(newTab, ListenerKey, tabListener); newTab.SetTabListener(tabListener); return(newTab); }
public void Apply(IMenu menu, Context context, object parent) { PlatformExtensions.ValidateTemplate(ItemsSource, Items); var setter = new XmlPropertySetter <IMenu>(menu, context, new BindingSet()); menu.SetBindingMemberValue(AttachedMembers.Object.Parent, parent); setter.SetBinding(nameof(DataContext), DataContext, false); setter.SetBoolProperty(nameof(IsVisible), IsVisible); setter.SetBoolProperty(nameof(IsEnabled), IsEnabled); if (!string.IsNullOrEmpty(Bind)) { setter.BindingSet.BindFromExpression(menu, Bind); } if (string.IsNullOrEmpty(ItemsSource)) { if (Items != null) { for (int index = 0; index < Items.Count; index++) { Items[index].Apply(menu, context, index, index); } } } else { menu.SetBindingMemberValue(AttachedMembers.Menu.ItemsSourceGenerator, new MenuItemsSourceGenerator(menu, context, ItemTemplate)); setter.SetBinding(nameof(ItemsSource), ItemsSource, true); } setter.Apply(); }
public void Apply(IMenu menu, Context context, object parent) { PlatformExtensions.ValidateTemplate(ItemsSource, Items); var setter = new XmlPropertySetter <MenuTemplate, IMenu>(menu, context, new BindingSet()); BindingExtensions.AttachedParentMember.SetValue(menu, parent); setter.SetBinding(template => template.DataContext, DataContext, false); setter.SetBoolProperty(template => template.IsVisible, IsVisible); setter.SetBoolProperty(template => template.IsEnabled, IsEnabled); if (string.IsNullOrEmpty(ItemsSource)) { if (Items != null) { for (int index = 0; index < Items.Count; index++) { Items[index].Apply(menu, context, index, index); } } } else { MenuItemsSourceGenerator.Set(menu, context, ItemTemplate); setter.SetBinding(template => template.ItemsSource, ItemsSource, true); } setter.Apply(); }
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); 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 { ActionBarTabItemsSourceGenerator.Set(actionBar, TabTemplate); setter.SetBinding(template => template.ItemsSource, ItemsSource, false); } setter.SetBinding(template => template.SelectedItem, SelectedItem, false); setter.Apply(); }
private ActionBar.Tab CreateTabInternal(ActionBar bar, object context, bool useContext) { var newTab = bar.NewTab(); newTab.SetBindingMemberValue(AttachedMembers.Object.Parent, bar); var setter = new XmlPropertySetter <ActionBarTabTemplate, ActionBar.Tab>(newTab, bar.ThemedContext, new BindingSet()); if (useContext) { newTab.SetDataContext(context); } else { setter.SetProperty(() => template => template.DataContext, DataContext); } if (!string.IsNullOrEmpty(Bind)) { setter.BindingSet.BindFromExpression(newTab, Bind); } setter.SetBinding(() => template => template.ContentTemplateSelector, ContentTemplateSelector, false); setter.SetProperty(() => template => template.ContentTemplate, ContentTemplate); setter.SetProperty(() => template => template.Content, Content); setter.SetStringProperty(() => template => template.ContentDescription, ContentDescription); setter.SetProperty(() => template => template.CustomView, CustomView); setter.SetProperty(() => template => template.Icon, Icon); setter.SetProperty(() => template => template.Text, Text); setter.SetProperty(() => template => template.Tag, Tag); setter.Apply(); var tabListener = new TabListener(new DataTemplateProvider(bar, AttachedMemberConstants.ContentTemplate, AttachedMemberConstants.ContentTemplateSelector)); ServiceProvider.AttachedValueProvider.SetValue(newTab, ListenerKey, tabListener); newTab.SetTabListener(tabListener); return(newTab); }
private ActionBar.Tab CreateTabInternal(ActionBar bar, object context, bool useContext) { var newTab = bar.NewTab(); newTab.SetBindingMemberValue(AttachedMembers.Object.Parent, bar); var setter = new XmlPropertySetter(newTab, bar.ThemedContext); if (useContext) { newTab.SetDataContext(context); } else { setter.SetProperty(nameof(DataContext), DataContext); } if (!string.IsNullOrEmpty(Bind)) { setter.Bind(newTab, Bind); } setter.SetBinding(nameof(ContentTemplateSelector), ContentTemplateSelector, false); setter.SetProperty(nameof(ContentTemplate), ContentTemplate); setter.SetProperty(nameof(Content), Content); setter.SetStringProperty(nameof(ContentDescription), ContentDescription); setter.SetProperty(nameof(CustomView), CustomView); setter.SetProperty(nameof(Icon), Icon); setter.SetProperty(nameof(Text), Text); setter.SetProperty(nameof(Tag), Tag); setter.Apply(); var tabListener = new TabListener(new DataTemplateProvider(bar, AttachedMemberConstants.ContentTemplate, AttachedMemberConstants.ContentTemplateSelector)); ServiceProvider.AttachedValueProvider.SetValue(newTab, ListenerKey, tabListener); newTab.SetTabListener(tabListener); return(newTab); }
private ActionBar.Tab CreateTabInternal(ActionBar bar, object context, bool useContext) { var newTab = bar.NewTab(); newTab.SetBindingMemberValue(AttachedMembers.Object.Parent, bar); var setter = new XmlPropertySetter<ActionBarTabTemplate, ActionBar.Tab>(newTab, bar.ThemedContext, new BindingSet()); if (useContext) newTab.SetDataContext(context); else setter.SetProperty(() => template => template.DataContext, DataContext); if (!string.IsNullOrEmpty(Bind)) setter.BindingSet.BindFromExpression(newTab, Bind); setter.SetBinding(() => template => template.ContentTemplateSelector, ContentTemplateSelector, false); setter.SetProperty(() => template => template.ContentTemplate, ContentTemplate); setter.SetProperty(() => template => template.Content, Content); setter.SetStringProperty(() => template => template.ContentDescription, ContentDescription); setter.SetProperty(() => template => template.CustomView, CustomView); setter.SetProperty(() => template => template.Icon, Icon); setter.SetProperty(() => template => template.Text, Text); setter.SetProperty(() => template => template.Tag, Tag); setter.Apply(); var tabListener = new TabListener(new DataTemplateProvider(bar, AttachedMemberConstants.ContentTemplate, AttachedMemberConstants.ContentTemplateSelector)); ServiceProvider.AttachedValueProvider.SetValue(newTab, ListenerKey, tabListener); newTab.SetTabListener(tabListener); return newTab; }
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(); }
public void Apply(Activity activity) { AndroidToolkitExtensions.ValidateTemplate(ItemsSource, Items); var actionBar = activity.GetActionBar(); var setter = new XmlPropertySetter(actionBar, activity); setter.SetEnumProperty <ActionBarNavigationMode>(nameof(NavigationMode), NavigationMode); setter.SetProperty(nameof(DataContext), DataContext); if (!string.IsNullOrEmpty(Bind)) { setter.Bind(actionBar, Bind); } setter.SetProperty(nameof(ContextActionBarTemplate), ContextActionBarTemplate); setter.SetBinding(nameof(ContextActionBarVisible), ContextActionBarVisible, false); setter.SetProperty(nameof(BackgroundDrawable), BackgroundDrawable); setter.SetProperty(nameof(CustomView), CustomView); setter.SetEnumProperty <ActionBarDisplayOptions>(nameof(DisplayOptions), DisplayOptions); setter.SetBoolProperty(nameof(DisplayHomeAsUpEnabled), DisplayHomeAsUpEnabled); setter.SetBoolProperty(nameof(DisplayShowCustomEnabled), DisplayShowCustomEnabled); setter.SetBoolProperty(nameof(DisplayShowHomeEnabled), DisplayShowHomeEnabled); setter.SetBoolProperty(nameof(DisplayShowTitleEnabled), DisplayShowTitleEnabled); setter.SetBoolProperty(nameof(DisplayUseLogoEnabled), DisplayUseLogoEnabled); setter.SetBoolProperty(nameof(HomeButtonEnabled), HomeButtonEnabled); setter.SetProperty(nameof(Icon), Icon); setter.SetProperty(nameof(Logo), Logo); setter.SetProperty(nameof(SplitBackgroundDrawable), SplitBackgroundDrawable); setter.SetProperty(nameof(StackedBackgroundDrawable), StackedBackgroundDrawable); setter.SetBoolProperty(nameof(IsShowing), IsShowing); setter.SetStringProperty(nameof(Subtitle), Subtitle); setter.SetStringProperty(nameof(Title), Title); setter.SetBoolProperty(nameof(Visible), Visible); setter.SetBinding(AttachedMembers.ActionBar.HomeButtonClick, HomeButtonClick, false); if (string.IsNullOrEmpty(ItemsSource)) { if (Items != null) { ActionBar.Tab firstTab = null; for (int index = 0; index < Items.Count; index++) { var tab = Items[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(nameof(ItemsSource), ItemsSource, false); } setter.SetBinding(nameof(SelectedItem), SelectedItem, false); setter.Apply(); }