TabItem in a separate XAML

If what you want to do is simply make the code more manageable then I would recommend defining each tab’s data in a user control, but still have the TabItem in the main tab control. Let’s assume that your original code was this: <TabControl> <TabItem Header=”Tab 1″> <Grid> <TextBlock Text=”Tab Data” /> </Grid> </TabItem> </TabControl> … Read more

WPF – TabItem Background color changes when tabitem selected or hover over

Here is example of TabItem ControlTemplate Copy it to your resources and set wherever you need Red color as Background. SAMPLE <Window x:Class=”TestCustomTab.Window1″ xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”Window1″ Height=”300″ Width=”300″> <Window.Resources> <SolidColorBrush x:Key=”RedBrush” Color=”Red”/> <SolidColorBrush x:Key=”SolidBorderBrush” Color=”#888″ /> <SolidColorBrush x:Key=”GreenBrush” Color=”Green” /> <SolidColorBrush x:Key=”DisabledBackgroundBrush” Color=”#EEE” /> <SolidColorBrush x:Key=”DisabledBorderBrush” Color=”#AAA” /> <SolidColorBrush x:Key=”DisabledForegroundBrush” Color=”#888″ /> <Style TargetType=”{x:Type TabItem}”> … Read more

In C# WPF, why is my TabControl’s SelectionChanged event firing too often?

The TabControl.SelectionChanged is the same event as a ComboBox.SelectionChanged It originates from Selector.SelectionChanged. So, if you do not mark your event as handled in your event handler, it will bubble up the tree, and eventually arrive at your TabControl, which is causing this “firing too often” issue. Mark your event as handled in your SelectionChanged … Read more