Jason Clark
Top achievements
Rank 1
Jason Clark
asked on 11 Feb 2010, 02:13 AM
Is it possible to close the drop down on mouseleave or something similar?
Thanks
4 Answers, 1 is accepted
0
Hello Jason,
RadComboBox cannot close its dropdown automatically when the mouse leaves it, but you could try to hook a handler on the MouseLeave event and when the e.OriginalSource == sender (e.g. the RadComboBox) you could set IsDropDownOpen = false.
Kind regards,
Valeri Hristov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
RadComboBox cannot close its dropdown automatically when the mouse leaves it, but you could try to hook a handler on the MouseLeave event and when the e.OriginalSource == sender (e.g. the RadComboBox) you could set IsDropDownOpen = false.
Kind regards,
Valeri Hristov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
kwitee
Top achievements
Rank 1
answered on 10 Feb 2012, 01:19 PM
Hi, I am trying to do something similar:
I want to close the RadDropDownButton when the mouse leaves the button OR the DropDownContent. But when the mouse
leaves the button and enters the DropDownContent, it should stay open.
Is there a simple way to do it?
-- regards,
kwitee
I want to close the RadDropDownButton when the mouse leaves the button OR the DropDownContent. But when the mouse
leaves the button and enters the DropDownContent, it should stay open.
Is there a simple way to do it?
-- regards,
kwitee
0
Hello Ondra,
Give it a try and let me know if this approach suites your scenario. Greetings,
Kiril Stanoev
the Telerik team
One way to achieve this scenario is to use a DispatcherTimer and couple of bool flags:
<
telerik:RadDropDownButton
x:Name
=
"dropDownButton"
Content
=
"DropDownButton"
MouseLeave
=
"DropDownButton_MouseLeave"
MouseEnter
=
"DropDownButton_MouseEnter"
>
<
telerik:RadDropDownButton.DropDownContent
>
<
Grid
Width
=
"200"
Height
=
"200"
Background
=
"LightGreen"
MouseEnter
=
"Content_MouseEnter"
MouseLeave
=
"Content_MouseLeave"
/>
</
telerik:RadDropDownButton.DropDownContent
>
</
telerik:RadDropDownButton
>
using
System;
using
System.Linq;
using
System.Windows.Controls;
using
System.Windows.Input;
using
System.Windows.Threading;
public
partial
class
MainPage : UserControl
{
private
bool
buttonMouseInside, contentMouseInside;
DispatcherTimer timer =
new
DispatcherTimer();
public
MainPage()
{
this
.InitializeComponent();
this
.timer.Interval = TimeSpan.FromSeconds(0.5);
this
.timer.Tick +=
new
EventHandler(Timer_Tick);
}
private
void
CloseDropDownButton()
{
this
.timer.Stop();
this
.timer.Start();
}
private
void
Content_MouseEnter(
object
sender, MouseEventArgs e)
{
this
.contentMouseInside =
true
;
}
private
void
Content_MouseLeave(
object
sender, MouseEventArgs e)
{
this
.contentMouseInside =
false
;
this
.CloseDropDownButton();
}
private
void
DropDownButton_MouseEnter(
object
sender, MouseEventArgs e)
{
this
.buttonMouseInside =
true
;
}
private
void
DropDownButton_MouseLeave(
object
sender, MouseEventArgs e)
{
this
.buttonMouseInside =
false
;
this
.CloseDropDownButton();
}
private
void
Timer_Tick(
object
sender, EventArgs e)
{
if
(!
this
.buttonMouseInside && !
this
.contentMouseInside)
{
this
.dropDownButton.IsOpen =
false
;
}
}
}
Give it a try and let me know if this approach suites your scenario. Greetings,
Kiril Stanoev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
kwitee
Top achievements
Rank 1
answered on 15 Feb 2012, 12:42 PM
Hi,
your solution works fine for me. It was a little glitchy at first, but with smaller timer interval (0.2 sec) and negativ content top-margin it works like I wanted.
Thanks a lot.
-- regards
kwitee
your solution works fine for me. It was a little glitchy at first, but with smaller timer interval (0.2 sec) and negativ content top-margin it works like I wanted.
Thanks a lot.
-- regards
kwitee