RadDataBoundListBox clear all checked items in viewmodel

3 posts, 1 answers
  1. Daniele
    Daniele avatar
    7 posts
    Member since:
    May 2014

    Posted 14 Jul 2015 Link to this post

    Hi,

    I would like to clear all checked items in the viewmodel?

    Is it possible?

     

    I know that in the code behind I can use this code:

     

    MyList..CheckedItems.Clear();

     

    But since I would like to follow the mvvm pattern I would do it in the ViewModel of the page?

     

    Thanks in advanced.

    Daniele

  2. Answer
    Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 17 Jul 2015 Link to this post

    Hello Daniele, 

    You can achieve the described requirements by creating custom boolean attached property. Once you create it you will be able to bind it to a property from your ViewModel. This will allow you to trigger it from your ViewModel. On the other hand, in the PropertyChanged callback of the attached property you will be able to clear the CheckedItems collection using the DependencyObject argument.

    In addition to this the RadDataBoundListBox control exposes ItemCheckedStateChanged event. You can subscribe to it and you will be able to set back the property of your view model to its initial state when the event is invoked.

    I believe this will get you started. Do not hesitate to contact us again if you need any further assistance.

    Regards,
    Pavel R. Pavlov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. Daniele
    Daniele avatar
    7 posts
    Member since:
    May 2014

    Posted 18 Jul 2015 in reply to Pavel R. Pavlov Link to this post

    Thanks Pavel,

    by an attached property I could achieve my target.

     

    Thanks

    Daniele

Back to Top