Databinding to SelectedItems property of the GridView

8 posts, 0 answers
  1. David Sandor
    David Sandor avatar
    16 posts
    Member since:
    May 2009

    Posted 04 Jun 2010 Link to this post

    It seems impossible even though I am using a binding mode of OneWayToSource.  Are there plans to allow us to Databaing to this property.  It would be great to be able to Databind that to a collection on my viewmodel.

    Thanks,
    David Sandor
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 09 Jun 2010 Link to this post

    Hi David Sandor,

    Could you please take a look at this blog post.


    Regards,
    Milan
    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. David Sandor
    David Sandor avatar
    16 posts
    Member since:
    May 2009

    Posted 09 Jun 2010 Link to this post

    Hi Milan,

    That blog post does in fact address this issue.  I do feel though that the blog post is really making something that should be simple into a very complicated mess.  Using behaviors is really neat but I treat the GridView as my data provider and I expect standard behavior of the Grid to allow me to use standard databinging techniques to accomplish my goals.  Having to create a Bahavior is a hack.

    If I am going to go through the trouble of creating a hack for this problem I would rather add a 1 liner of code behind to accomplish the same:

    private void RadGridView_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)  
    {  
        viewModel.SetSelectedItems(((RadGridView)sender).SelectedItems);  

    SetSelectedItems basically adding to an ObservableCollection<> everything in .SelectedItems.

    Thanks for the help, but I would love to see the SelectedItems a bindable property unless there is some really good reason for it not to be bindable.

    David Sandor
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Jun 2010 Link to this post

    Hello David,

     SelectedItems is bindable however you cannot use TwoWay binding since the property is read-only. This is exactly the same as any standard Silverlight component with multiple selection.

    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. David Sandor
    David Sandor avatar
    16 posts
    Member since:
    May 2009

    Posted 09 Jun 2010 Link to this post

    Hi Vlad,

    Thanks for your response.  I am not sure if it matters, but I am using the WPF version.  If you read my original post on this topic and google around a bit you will note that you can not actually databind to that property.  As I stated earlier, it does not even work with OneWayToSource binding.  Please prove me wrong :)  I would love for that to work.

    Thanks,
    David Sandor
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Jun 2010 Link to this post

    Hi David,

     Sorry for the Silverlight confusion!

    The idea was to point that there is no Silverlight and/or WPF component with multiple selection read/write property. As to the binding you can check our "Selection" example - ListBox on the right is bound SelectedItems.

    If you know any component (ItemsControl, ListBox, etc.) with "SelectedItems" property with setter please post it!

    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.
  8. Steve
    Steve avatar
    20 posts
    Member since:
    Jan 2011

    Posted 21 Oct in reply to Vlad Link to this post

    6 years later.... RadAutoCompleteBox has this!

    Does that mean you can implement it in RadGridView now? :-)

  9. Martin Vatev
    Admin
    Martin Vatev avatar
    90 posts

    Posted 26 Oct Link to this post

    Hello Steve,

    I do understand your point regarding the SelectedItems property of RadAutoCompleteBox, however, the architecture of the selection functionality of RadGridView is designed in such manner, that its SelectedItems property should be left to be read-only. 
    As already mentioned in the forum the SelectedItems property is bindable but only using OneWay binding as is presented in our "Selection" example.

    Regards,
    Martin Vatev
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Back to Top
UI for WPF is Visual Studio 2017 Ready