I have a TabControl with a custom TabItem. The view xaml looks like this.
<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">
<Grid>
<TabControl>
<TabItem Header="TabItem 4" />
<local:CustomTabItem Header="Testing" />
</TabControl>
</Grid>
</UserControl>
the CustomTabItem.xaml file looks like this
<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">
<Style TargetType="{x:Type local:CustomTabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomTabItem}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
and the CustomTabItem.xaml.cs file looks like this
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)));
}
}
}
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 DefaultStyleKeyProperty
line in CustomTabItem.aspx.cs.
I've probably got this all set up wrong anyways. Ultimate goal is to have closeable tabs.