I have a WPF TabControl that has a couple of buttons in the TabItem header. I want the selected tab to change when a headered button is clicked. Here is a code snippet:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<TabControl>
<TabItem Content="Item 1 Content">
<TabItem.Header>
<StackPanel Orientation="Vertical">
<TextBlock FontSize="14" FontWeight="Bold" Text="Item1"/>
<StackPanel Orientation="Horizontal">
<Button Content="Action 1"/>
<Button Content="Action 2"/>
</StackPanel>
</StackPanel>
</TabItem.Header>
</TabItem>
<TabItem Content="Item 2 Content">
<TabItem.Header>
<StackPanel Orientation="Vertical">
<TextBlock FontSize="14" FontWeight="Bold" Text="Item2"/>
<StackPanel Orientation="Horizontal">
<Button Content="Action 1"/>
<Button Content="Action 2"/>
</StackPanel>
</StackPanel>
</TabItem.Header>
</TabItem>
</TabControl>
</Grid>
</Page>
This sample show a couple of Tabs. A tab is selected if the header background is clicked, however, if a button is clicked the tab is not selected. I want the button to accept the click but I also want the tab corresponding to the button to get selected. Can anyone help?
Thanks, Hitesh