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

Prevent focus when ScrollIntoView

3 Answers 141 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas Andersson
Top achievements
Rank 1
Thomas Andersson asked on 02 Feb 2010, 02:13 PM
Hello

I am building a windows application using the MVVM pattern.

My scenario is as following:
I have a window with several viewmodels in it.

(VM1) Viewmodel containing a list of items displayed through it's view with the help of RadGridView. 

(VM2) Viewmodel with a search-like function, given a search criteria it sets the SelectedItem in VM1.

My first problem was that the selecteditem could be out of view. I made a mvvm-exception and added code behind and used ScrollIntoView to solve that problem (works like a charm).

private void SelectionChangedHandler(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)  
{  
   if (this.radGridView.SelectedItem != null)  
   {  
        this.radGridView.ScrollIntoView(radGridView.SelectedItem);  
   }  
My problem now is that when scrolling occurs, the RadGridView gains focus. Is there any way to prevent this?

Best regards and thanks.
Thomas

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan Dobrev
Telerik team
answered on 08 Feb 2010, 08:28 AM
Hi Thomas,

I believe there is no way to prevent this currently. When you call ScrollIntoView(...) we call BringIntoView() internally which will focus the element. We will look into ways to improve this functionality in the future, in order to prevent the unnecessary focus.

As for a current workaround I can suggest you to use the ScrollIntoViewAsync(...) method we have introduced in one of our latest internal builds. You can pass it an action which will be executed after the item has been scrolled. In this action you can focus whatever element you want.

Hope this helps,
Stefan Dobrev
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Thomas Andersson
Top achievements
Rank 1
answered on 08 Feb 2010, 08:40 AM
Thank you for your answer.

"We will look into ways to improve this functionality in the future, in order to prevent the unnecessary focus."

This sounds promising.


Will ScrollIntoViewAsync be in the next version of the Grid you release?
0
Hristo
Telerik team
answered on 08 Feb 2010, 01:42 PM
Hello Thomas,

ScrollIntoViewAsync is available in our latest internal build version 2009.3.1405. You can download it from your account and give it a try.

Sincerely yours,
Hristo
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
GridView
Asked by
Thomas Andersson
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Thomas Andersson
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or