I have a number of WPF RadComboBox controls in a WPF window and am handling the LostFocus event for each one so that I know which field has just been left. However, when a RadComboBox control gets focus via a mouse click it seems to fire a LostFocus event before its GotFocus event, which is causing my code to think it's left a field before it's even got there! This appears to be different behaviour from the other Rad input controls I'm using (e.g. RadWatermarkTextBox, RadDateTimePicker, etc).
Note that this problem only occurs when changing focus between the fields using mouse clicks. It doesn't appear to occur when navigating between the fields using the Tab key.
Is this a known bug or am I doing something wrong? Either way, is there a fix or workaround available.
The following is the xaml and code behind from a sample WPF window I created to highlight the problem...
Note that this problem only occurs when changing focus between the fields using mouse clicks. It doesn't appear to occur when navigating between the fields using the Tab key.
Is this a known bug or am I doing something wrong? Either way, is there a fix or workaround available.
The following is the xaml and code behind from a sample WPF window I created to highlight the problem...
<
Window
x:Class
=
"MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"*"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
StackPanel
Grid.Row
=
"0"
Height
=
"Auto"
HorizontalAlignment
=
"Stretch"
Name
=
"StackPanel1"
VerticalAlignment
=
"Stretch"
Width
=
"Auto"
>
<
telerik:RadComboBox
Name
=
"Combo1"
Text
=
"One"
Margin
=
"2"
IsEditable
=
"True"
GotFocus
=
"RadComboBox_GotFocus"
LostFocus
=
"RadComboBox_LostFocus"
>
<
telerik:RadComboBox.Items
>
<
telerik:RadComboBoxItem
>One</
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
>Two</
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
>Three</
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
>Four</
telerik:RadComboBoxItem
>
</
telerik:RadComboBox.Items
>
</
telerik:RadComboBox
>
<
telerik:RadComboBox
Name
=
"Combo2"
Text
=
"Six"
Margin
=
"2"
IsEditable
=
"True"
GotFocus
=
"RadComboBox_GotFocus"
LostFocus
=
"RadComboBox_LostFocus"
>
<
telerik:RadComboBox.Items
>
<
telerik:RadComboBoxItem
>Five</
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
>Six</
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
>Seven</
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
>Eight</
telerik:RadComboBoxItem
>
</
telerik:RadComboBox.Items
>
</
telerik:RadComboBox
>
<
telerik:RadComboBox
Name
=
"Combo3"
Text
=
"Eleven"
Margin
=
"2"
IsEditable
=
"True"
GotFocus
=
"RadComboBox_GotFocus"
LostFocus
=
"RadComboBox_LostFocus"
>
<
telerik:RadComboBox.Items
>
<
telerik:RadComboBoxItem
>Nine</
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
>Ten</
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
>Eleven</
telerik:RadComboBoxItem
>
<
telerik:RadComboBoxItem
>Twelve</
telerik:RadComboBoxItem
>
</
telerik:RadComboBox.Items
>
</
telerik:RadComboBox
>
</
StackPanel
>
<
ListBox
Grid.Row
=
"1"
Height
=
"Auto"
HorizontalAlignment
=
"Stretch"
Name
=
"EventList"
VerticalAlignment
=
"Stretch"
Width
=
"Auto"
/>
</
Grid
>
</
Window
>
Imports
Telerik.Windows.Controls
Class
MainWindow
Private
Sub
RadComboBox_GotFocus(sender
As
System.
Object
, e
As
System.Windows.RoutedEventArgs)
Dim
cbo =
CType
(sender, RadComboBox)
AddEventToList(cbo.Name,
"GotFocus"
)
End
Sub
Private
Sub
RadComboBox_LostFocus(sender
As
System.
Object
, e
As
System.Windows.RoutedEventArgs)
Dim
cbo =
CType
(sender, RadComboBox)
AddEventToList(cbo.Name,
"LostFocus"
)
End
Sub
Private
Sub
AddEventToList(
ByVal
ctrlName
As
String
,
ByVal
eventName
As
String
)
EventList.Items.Add(
String
.Format(
"{0} : {1} : {2}"
, EventList.Items.Count, ctrlName, eventName))
EventList.ScrollIntoView(EventList.Items(EventList.Items.Count - 1))
End
Sub
End
Class