protected override void OnApplyTemplate() { var popupRadius = (CornerRadius)ResourceAccessor.ResourceLookup(this, c_overlayCornerRadiusKey); var tabView = SharedHelpers.GetAncestorOfType <TabView>(VisualTreeHelper.GetParent(this)); var internalTabView = tabView ?? null; Button GetCloseButton(TabView internalTabView) { var closeButton = (Button)GetTemplateChild("CloseButton"); if (closeButton != null) { // Do localization for the close button automation name if (string.IsNullOrEmpty(AutomationProperties.GetName(closeButton))) { var closeButtonName = ResourceAccessor.GetLocalizedStringResource(SR_TabViewCloseButtonName); AutomationProperties.SetName(closeButton, closeButtonName); } if (internalTabView != null) { // Setup the tooltip for the close button var tooltip = new ToolTip(); tooltip.Content = internalTabView.GetTabCloseButtonTooltipText(); ToolTipService.SetToolTip(closeButton, tooltip); } closeButton.Click += OnCloseButtonClick; } return(closeButton); } m_closeButton = GetCloseButton(internalTabView); OnIconSourceChanged(); if (tabView != null) { if (SharedHelpers.IsThemeShadowAvailable()) { if (internalTabView != null) { var shadow = new ThemeShadow(); if (!SharedHelpers.Is21H1OrHigher()) { if (internalTabView.GetShadowReceiver() is UIElement shadowReceiver) { shadow.Receivers.Add(shadowReceiver); } } m_shadow = shadow; double shadowDepth = (double)SharedHelpers.FindInApplicationResources(TabView.c_tabViewShadowDepthName, TabView.c_tabShadowDepth); var currentTranslation = Translation; var translation = new Vector3(currentTranslation.X, currentTranslation.Y, (float)shadowDepth); Translation = translation; UpdateShadow(); } } tabView.TabDragStarting += OnTabDragStarting; tabView.TabDragCompleted += OnTabDragCompleted; } UpdateCloseButton(); UpdateWidthModeVisualState(); }