I have a WPF application that uses a ComboBox with items populated from the server. The control works well in it’s current setup but has a small issue that I would like to resolve. When I click on the DropDown button to open the list of items I can only select items if the mouse is hovering over the text of that item. If I have the mouse hover over the row but not directly on the text then the control doesn’t seem to recognize that row should be selected. Is there anyway to set focus on the current row and not just on the item?
EDIT
The comboBox is stored in a UserControl that derives from a class that handles network transmission between the client and the server. The XAML just creates the control and assigns a name for it while the code behind does all of the logic. In this case the server sends information to be used for the combobox and in the snippet provided below takes the XML with the text items and assigns them to the control itself. This all works well but the problem is when the client tries to select the item. Unless the mouse is directly over the text the ComboBox doesn’t register. I would like to have it so that the ComboBox selects the item as long as the mouse is over the same row as the text.
XAML
<local:Control x:Class="ControlLibrary.ComboBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ControlLibrary" >
<ComboBox Name="comboBox" FontWeight="Bold" />
</local:Control>
C#
XmlNodeList nodelist = xmlNode.SelectNodes("Items");
comboBox.Items.Clear();
foreach (XmlNode node in nodelist)
{
ComboBoxItem tempItem = new ComboBoxItem()
{
Content = node.Attributes["text"].Value
};
comboBox.Items.Add(tempItem);
}
Thanks in advance for the advice.
Try to place this text box inside a dockpanel or grid