'How to set TabItem's header from code-behind WPF
I have a menu with RadioButton that opens a new tab when checked, now when I create the new tab I'm trying to add a style for the header in App.XAML but when I try to add an event to the (x) to close the tab it takes me to App.XAML.CS which I don't want to, because on that page I can't reach the TabControl that exists in my MainWindow
So I'm trying to add the style from Code-Behind but I didn't find out how to do it.
This is my style
<Border
x:Name="PART_Border"
Background="{TemplateBinding Background}"
BorderThickness="1"
BorderBrush="{x:Null}"
Margin="5,-3,3,4"
CornerRadius="5">
<DockPanel>
<Button Name="btnDelete"
DockPanel.Dock="Right"
Margin="5 0 0 0"
Padding="0"
Click="BtnCloseTab_Click"
Style="{DynamicResource TabCloseBtn}">
<Image Source="img\White\closeWhite.png" Height="11" Width="11"/>
</Button>
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=TabItem }, Path=Header}" />
</DockPanel>
</Border>
When I go to the event here it takes me to App.XAML.CS but I want to move to MainWindow.XAML.CS
I already search a lot about it but nothing was helpful for my situation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
