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

How to focus the templated dropdown content when drop down opened?

3 Answers 77 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
xu
Top achievements
Rank 1
xu asked on 05 Apr 2012, 11:19 AM

Hi,

I'm using the RadDropDownButton with a drop down content template to show a UserControl. I want the UserControl get focused on dropdown opened. I've tried the following code, but the DropDownContent property always return null.

dropDownBtn.DropDownOpened += (o, e) => 
{
    (dropDownBtn.DropDownContent as UserControl).Focus();
};
Help me please!

3 Answers, 1 is accepted

Sort by
0
Accepted
Zarko
Telerik team
answered on 06 Apr 2012, 02:57 PM
Hello,
If you're using UserControl as a DropDownContent of your DropDownButton you can handle the Loaded event of the UserControl and get the focus there:
private void MyUserControlLoaded(object sender, RoutedEventArgs e)
{
    this.Focus();
}
I've attached a sample project with this code so you could test it and if you have more questions please feel free to ask.

Kind regards,
Zarko
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
xu
Top achievements
Rank 1
answered on 09 Apr 2012, 07:33 AM
Thanks,that  works for me. But I'm just wandering why doesn't the RadDropDownButton focus the drop down content automaticly, so the user can use keyborad without any interuption.
0
Zarko
Telerik team
answered on 12 Apr 2012, 09:09 AM
Hello,
I'm glad that we were able to help you. As for the default behavior of the RadDropDownButton - we think that this is the expected behavior and also it's easier to manually focus the DropDownContent than to unfocus it (if this is the default behavior) and that's why we've made it this way.
If you have further questions please feel free to ask.

Regards,
Zarko
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Buttons
Asked by
xu
Top achievements
Rank 1
Answers by
Zarko
Telerik team
xu
Top achievements
Rank 1
Share this question
or