I have a TabControl
with three TabItems
. In each of the TabItems
is one ComboBox
. If I switch through the TabItems
the first entry of the ComboBoxes
is selected. But I want that nothing is selected. How to do it?
Here are some screenshots:
After the first call of the form, there is nothing selected
After the switch to the second tab, the first element of the combobox is selected
Update: This is the code for this example
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Width="525" SizeToContent="Height">
<Grid>
<TabControl>
<TabItem Header="Test 1">
<ComboBox>
<ComboBoxItem>Test 1</ComboBoxItem>
<ComboBoxItem>Test 2</ComboBoxItem>
</ComboBox>
</TabItem>
<TabItem Header="Test 2">
<ComboBox>
<ComboBoxItem>Test 1</ComboBoxItem>
<ComboBoxItem>Test 2</ComboBoxItem>
</ComboBox>
</TabItem>
<TabItem Header="Test 3">
<ComboBox>
<ComboBoxItem>Test 1</ComboBoxItem>
<ComboBoxItem>Test 2</ComboBoxItem>
</ComboBox>
</TabItem>
</TabControl>
</Grid>
No binding. A brand new project in Visual Studio Express 2010.
And here is the code behind:
using System.Windows;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
With your help and a long journey through the web, I now know, that there is no way to avoid the behavior, that the first focusable child on tabitem gets focused, without some code behind :(
Thank you all for your answers, especially @makc for his advice, that the blue background means, that the combobox is focused.