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);
        }
Ejemplo n.º 2
0
        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;
        }