[WPF]: Tab Control and TabItem (focus?) woes....

L

Lloyd Dupont

Here is a XAML snippet (which would run in XAML Pad as well):


<TabControl>
<TabItem Header="One">
<TabControl>
<TabItem Header="OK">
<Button Content="OK"/>
</TabItem>
<TabItem Header="Not OK">
<Button Content="Not OK"/>
</TabItem>
</TabControl>
</TabItem>
<TabItem Header="Two">
<TabControl>

<TabControl.Template>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid KeyboardNavigation.TabNavigation="Local"
SnapsToDevicePixels="true" ClipToBounds="true">
<Grid.RowDefinitions>
<RowDefinition Name="RowDefinition0"
Height="Auto" />
<RowDefinition Name="RowDefinition1" Height="*"
/>
</Grid.RowDefinitions>
<DockPanel>
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal"
Name="HeaderPanel" ZIndex="1" KeyboardNavigation.TabIndex="1"
IsItemsHost="true" />
<Label Content="Something" />
</DockPanel>
<ContentPresenter Name="PART_SelectedContentHost"
Grid.Column="0" Grid.Row="1" SnapsToDevicePixels="{TemplateBinding
SnapsToDevicePixels}" Margin="{TemplateBinding Padding}"
ContentSource="SelectedContent" />
</Grid>
</ControlTemplate>
</TabControl.Template>
<TabItem Header="Apple">
<Button Content="One Apple a day, keep the doctors away"/>
</TabItem>
<TabItem Header="Carrot">
<Button Content="One carrot a day, ho well, nothing special"/>
</TabItem>
</TabControl>
</TabItem>
</TabControl>

Where every time you select the TabItem "Two" (in the toplevel tab) the
inner TabControl would change its selected item.
(every second time it will be "Apple" every other second time it will be
"Carrot")

Why does the inner tab changes?

How to work around this bug?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top