示例#1
0
 private static void TabControlProperty_ValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != null)
     {
         TabContent.GetContentManager((TabControl)e.NewValue, (Border)d).UpdateSelectedTab();
     }
 }
示例#2
0
 private static void PersistProperty_ValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (!(d is TabControl tabControl))
     {
         return;
     }
     if ((bool)e.NewValue)
     {
         if (tabControl.ContentTemplate != null || tabControl.ContentTemplateSelector != null)
         {
             throw new InvalidOperationException($"{nameof(TabControl.ContentTemplate)} and {nameof(TabControl.ContentTemplateSelector)} must be null when Persist is true.");
         }
         tabControl.ContentTemplate = TabContent._template;
         TabContent._contentTemplateDescriptor.AddValueChanged(tabControl, TabContent.TabControl_ContentTemplatePropertiesChanged);
         TabContent._contentTemplateSelectorDescriptor.AddValueChanged(tabControl, TabContent.TabControl_ContentTemplatePropertiesChanged);
     }
     else
     {
         TabContent._contentTemplateDescriptor.RemoveValueChanged(tabControl, TabContent.TabControl_ContentTemplatePropertiesChanged);
         TabContent._contentTemplateSelectorDescriptor.RemoveValueChanged(tabControl, TabContent.TabControl_ContentTemplatePropertiesChanged);
         tabControl.ContentTemplate = null;
         using (TabContent.GetContentManager(tabControl))
         {
             TabContent.SetContentManager(tabControl, null);
         }
     }
 }
示例#3
0
        private static ContentManager GetContentManager(TabControl tabControl, Border border)
        {
            ContentManager?manager = TabContent.GetContentManager(tabControl);

            if (manager == null)
            {
                TabContent.SetContentManager(tabControl, manager = new ContentManager(tabControl));
            }
            manager.Container = border;
            return(manager);
        }