?
Solved

LostFocus Fires When ComboBox Receives Focus

Posted on 2010-03-29
2
Medium Priority
?
3,584 Views
Last Modified: 2013-11-12
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"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Page1">
    <Grid>
        <UniformGrid Rows="10" Columns="3">
            <Label>Some Text</Label>
            <TextBox></TextBox>
            <TextBox></TextBox>
            <Label>Stuff</Label>
            <ComboBox Name="ComboBox1" IsEditable="True">
                <ComboBoxItem>Apples</ComboBoxItem>
                <ComboBoxItem>Oranges</ComboBoxItem>
                <ComboBoxItem>Grapes</ComboBoxItem>
            </ComboBox>
        </UniformGrid>
    </Grid>
</Page>

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

0
Comment
Question by:jmgroft
2 Comments
 
LVL 16

Accepted Solution

by:
CuteBug earned 500 total points
ID: 29067501
0
 

Author Comment

by:jmgroft
ID: 29088292
THank you.  Somehow I missed that one when I searched for solutions.  Thanks for finding it .
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses
Course of the Month7 days, 8 hours left to enroll

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question