troubleshooting Question

LostFocus Fires When ComboBox Receives Focus

Avatar of jmgroft
jmgroft asked on
Microsoft Development
2 Comments1 Solution4033 ViewsLast Modified:
I have a WPF application with a combobox on it.  The combobox has its IsEditable property set to True.  For some reason, when IsEditable is set to True, the LostFocus event fires when the combobox receives focus.  It also fires when the combo box loses focus.  Can anyone explain why?  I'm guessing that the combobox is actually a composite control and some underlying piece is losing focus when the user enters the text portion of the combobox.

Ultimately, I'd like to find a way to ignore this event when it first receives focus and only fire it when the combobox truly loses focus.  I'm not sure how to accomplish that at this point.  I'm hoping someone else has run into this issue and knows a good way around it.

By the way, I've attached some very simple XAML and some code-behind to create a test form.
XAML for Text Page:
<Page x:Class="Page1"
        <UniformGrid Rows="10" Columns="3">
            <Label>Some Text</Label>
            <ComboBox Name="ComboBox1" IsEditable="True">

The Code-Behind:
Class Page1 
    Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles ComboBox1.LostFocus
        MessageBox.Show("LostFocus Fired")
    End Sub
End Class

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros