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

SelectedItems not responding to changes

9 Answers 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kilhoffer
Top achievements
Rank 1
kilhoffer asked on 05 Aug 2010, 05:35 PM
I have a Telerik GridView inside a UserControl that's contained in a document panel in a composite WPF application. When I first bring the view into place, I programatically add a default selected item by calling SelectedItems.Add(item) and everything works fine. Once I give another document tab focus in the application, I notice the Unloaded event fires on the Telerik grid. When I return to that view (give the tab focus), the SelectedItems collection does not respond to method calls such as .Clear() or .Add(). No exception is thrown, but nothing happens either. For example, if there are 3 items in the SelectedItems collection and I call .Clear() on it, in the debugger, I inspect the collection only to find it still has the same 3 items in it. 

My question is, what makes SelectedItems stop responding to changes? Is it the fact that somehow the Unloaded event is fired, or is that just a coincedence? I've tried creating the grid in a simple standalone application, but the SelectedItems collection always responds to changes. I can't help but think this is causes by by the underlying FrameworkElement being unloaded. 

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 09 Aug 2010, 08:59 AM
Hello,

I've just tried this with grid nor part of the visual tree however everything worked as expected. Here is an example. 


            var grid = new RadGridView();
            grid.ItemsSource = new int[] { 1,2,3};
            grid.SelectedItems.Add(((int[])grid.ItemsSource).LastOrDefault());


 Why not use the MVVM approach demonstrated in this blog post? You can work directly with the view model instead RadGridView. 

Greetings,
Vlad
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
kilhoffer
Top achievements
Rank 1
answered on 09 Aug 2010, 06:28 PM
It works in all of our simplified examples, too. But when the grid is placed in a docked document pane, we see problems. Manipulating the SelectedItems collection works as advertised until the pane loses focus. Once focus is regained, the SelectedItems collection does not respond to .Add, .Remove, or .Clear methods.

Also, I have tried the binding method you proposed. No matter how we bind the grid, the behavior is the same. Should I open a support ticket on this?
0
Vlad
Telerik team
answered on 10 Aug 2010, 06:40 AM
Hello,

 Please open support ticket and send us an example application where we can debug the grid behavior locally. 

Kind regards,
Vlad
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
Mike
Top achievements
Rank 1
answered on 01 Jul 2013, 09:13 PM
Hello,

I have exactlly the same problem. 
Can you tell me if you've found a solution to resolve this issue.

Thanks & Regards
Radouan
0
Dimitrina
Telerik team
answered on 02 Jul 2013, 11:12 AM
Hello Radouan,

This forum thread is quite old, so would you please share some additional details on your exact problem? Have you bound the SelectedItems collection to a property in your ViewModel? What is the version of the controls do you use, is it the latest version?

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Mike
Top achievements
Rank 1
answered on 02 Jul 2013, 12:01 PM
Hello Didie,

Thanks for quick replay. 
My problem is exactlly described in this topic:

When the grid is placed in a docked document pane, we see problems. Manipulating the SelectedItems collection works as advertised until the pane visibility change to collapsed. Once the visibility is set to Visibile, the SelectedItems collection does not respond to .Add, .Remove, or .Clear methods. 

I'm using the last version of Telerik RadControls for WPF.

Thanks.


0
Dimitrina
Telerik team
answered on 04 Jul 2013, 02:42 PM
Hi,

I tried to reproduce the problem with the SelectedItems, but unfortunately I were not able to.
As I am not sure how you have defined the panes, I have attached my test project. Would you please change it to illustrate the issue?

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Mike
Top achievements
Rank 1
answered on 05 Jul 2013, 11:30 AM
Hi Didie, 

Thanks for sharing your sample. I have changed your code and I can reproduce the issue, but I can't upload it. 
What you should do (or what I have in my application) that reproduce this problem is changing the visibility of the grid that contain the main content, called usually RootLayout.

Please try to select elements and then Hide the main grid and after Change Visibliity  to Visible of the main Grid, then your selectedItem is null. 

Thanks & regards
Radouan
0
Dimitrina
Telerik team
answered on 05 Jul 2013, 11:48 AM
Hello Radouan,

Indeed, there in not an option to attach project to a support thread. In order to be able to do so, you should open a support ticket.
I have modified the demo as per your description, but I am still not able to reproduce the issue. 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
kilhoffer
Top achievements
Rank 1
Answers by
Vlad
Telerik team
kilhoffer
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or