Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# WPF comboBox strange issue

Tags:

c#

combobox

wpf

I've two comboBoxes one above another. The problem appear if you open the form that contain this comboBoxes and avoid mouse over at lower comboBox, you just click on first comboBox and from drop down list choose item that is located right over the second comboBox. Once you click on an item the drop down list will close but your mouse will remain over the second comboBox. But this comboBox will not highlight and react on your clicks at all. Take a look at this picture please:

enter image description here

Both comboBoxes IsEditable = false; But if you move your mouse out of the 2nd comboBox and back over to it - everything will works fine. Help me please how to fix this.

UPD. XAML:

<ComboBox Background="{x:Null}" Height="33" HorizontalAlignment="Left" IsEditable="False" IsEnabled="True" Margin="10,151,0,0" Name="comboBox2" VerticalAlignment="Top" Width="239" VerticalContentAlignment="Center" FontSize="14" IsReadOnly="False" Text="" SelectionChanged="comboBox2_SelectionChanged" TabIndex="6" HorizontalContentAlignment="Left" Padding="10,3" FontWeight="SemiBold" AllowDrop="False" Cursor="Hand" IsTabStop="True" />
<ComboBox Background="{x:Null}" FontSize="14" Height="33" HorizontalAlignment="Left" IsEditable="False" IsEnabled="True" Margin="10,190,0,0" Name="comboBox3" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="439" IsReadOnly="False" Text="" SelectionChanged="comboBox3_SelectionChanged" TabIndex="8" HorizontalContentAlignment="Left" Padding="10,3" FontWeight="SemiBold" ClipToBounds="False" Cursor="Hand" IsHitTestVisible="True" SnapsToDevicePixels="True" UseLayoutRounding="True" />
like image 694
Mike Avatar asked Aug 03 '13 23:08

Mike


1 Answers

Set Background property to White or Transparent instead of {x:Null}. Null background affects control hit-test behavior.

like image 174
max Avatar answered Oct 03 '22 23:10

max