This is a migrated thread and some comments may be shown as answers.

Disabled Events Still Firing (for DropDownOpened)

2 Answers 28 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
sculver
Top achievements
Rank 1
sculver asked on 31 Aug 2009, 08:16 PM
I am developing a solution where I will need to go and pull information dynamically from a web service.

When the call is complete, I wish to open the drop down so the user will see all the results. However, I also need to run code in the DropDownOpened event as well, and do NOT need it to fire during this time. (I.e., when the user tells it to open, I need to run some code, but when the code auto opens it, I need something else).

I thought this would be no problem, as I should be able to unsubscribe from the event using the standard -= ????? However, to my surprise, even though I did this, the event still fires.  So for example, if I did this:

radMyCombo.DropDownOpened -= new EventHandler(MyEventHandler);
radMyCombo.IsDropDownOpen = true;
radMyCombo.DropDownOpened += new EventHandler(MyEventHandler);

I expected this to work, but it did not.  What am I missing????

2 Answers, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 01 Sep 2009, 09:17 AM
Hello Stephen,

The problem is because the DropDownOpened event is asynchronous, e.g. it is raised in a Dispatcher.BeginInvoce callback. I will check whether this is needed anymore, I remember fixing a problem in an older version this way (I know, it is a bad thing to use Dispatcher), which might be irrelevant now. To workaround the problem I would recommend using a flag:
- when you populate the combo you rise the flag, then open the dropdown
- when the dropdown opens, if the flag is raised, do nothing, but lower the flag, otherwise execute the code you need.

Kind regards,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
sculver
Top achievements
Rank 1
answered on 03 Sep 2009, 08:08 PM
Thanks, I did the workaround and got it to work.
Tags
ComboBox
Asked by
sculver
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
sculver
Top achievements
Rank 1
Share this question
or