SelectedItems not responding to changes

10 posts, 0 answers
  1. kilhoffer
    kilhoffer avatar
    40 posts
    Member since:
    May 2007

    Posted 05 Aug 2010 Link to this post

    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. 
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Aug 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. kilhoffer
    kilhoffer avatar
    40 posts
    Member since:
    May 2007

    Posted 09 Aug 2010 Link to this post

    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?
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Aug 2010 Link to this post

    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
  6. Mike
    Mike avatar
    75 posts
    Member since:
    Nov 2011

    Posted 01 Jul 2013 Link to this post

    Hello,

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

    Thanks & Regards
    Radouan
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 02 Jul 2013 Link to this post

    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 >>
  8. Mike
    Mike avatar
    75 posts
    Member since:
    Nov 2011

    Posted 02 Jul 2013 Link to this post

    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.


  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 04 Jul 2013 Link to this post

    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 >>
  10. Mike
    Mike avatar
    75 posts
    Member since:
    Nov 2011

    Posted 05 Jul 2013 Link to this post

    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
  11. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 05 Jul 2013 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready