Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF custom TabItem disappears upon restyle?
    text
    copied!<p>I have a TabControl with a custom TabItem. The view xaml looks like this.</p> <pre class="lang-xml prettyprint-override"><code>&lt;UserControl x:Class="PeripheryModule.Views.MainTabView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:PeripheryModule.Controls" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"&gt; &lt;Grid&gt; &lt;TabControl&gt; &lt;TabItem Header="TabItem 4" /&gt; &lt;local:CustomTabItem Header="Testing" /&gt; &lt;/TabControl&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p>the CustomTabItem.xaml file looks like this</p> <pre class="lang-xml prettyprint-override"><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:PeripheryModule.Controls"&gt; &lt;Style TargetType="{x:Type local:CustomTabItem}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type local:CustomTabItem}"&gt; &lt;Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>and the CustomTabItem.xaml.cs file looks like this</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace PeripheryModule.Controls { public class CustomTabItem : TabItem { static CustomTabItem() { DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomTabItem), new FrameworkPropertyMetadata(typeof(CustomTabItem))); } } } </code></pre> <p>I get no errors thrown, all that happens is the tabItem simply doesn't show up. It will, however, show up if i comment out the <code>DefaultStyleKeyProperty</code> line in CustomTabItem.aspx.cs.</p> <p>I've probably got this all set up wrong anyways. Ultimate goal is to have closeable tabs.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload