I have a TabControl , where is TabItem DataTemplat ed. The template seems to work correctly since the user control that I want to show in TabItem is displayed correctly.
I'm not sure how to get the "x" to display in the TabItem so that I can close each tab, as they are dynamically generated through the template.
Being fairly new to WPF, I am starting to understand many concepts, but TabControl given me a lot of trouble, so I can work very well with a template, but not a supported one.
This is what I have, and I would like to be able to close each TabControl . I should also be able to fire a custom event when TabControl closes.
<UserControl x:Class="Russound.Windows.UI.UserControls.CallLog.CaseReaderWpf" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:CallLog="clr-namespace:Russound.Windows.UI.UserControls.CallLog" Height="637" Width="505"> <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Russound.Windows;component/UI/RussoundDictionary.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources> <TabControl x:Name="tabCases" > <TabControl.ItemTemplate> <DataTemplate DataType="{x:Type TabItem}"> <StackPanel> <TextBlock Text="{Binding Path=Id}" /> </StackPanel> </DataTemplate> </TabControl.ItemTemplate> <TabControl.ContentTemplate> <DataTemplate DataType="{x:Type TabItem}"> <CallLog:CaseReadOnlyDisplay DataContext="{Binding}" /> </DataTemplate> </TabControl.ContentTemplate> </TabControl> </UserControl>
source share