SelectedItem binding with self-reference example

4 posts, 1 answers
  1. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 22 Oct 2013 Link to this post

    Hi
    I've got an MVVM example of a RadTreeView (Q3 2013) bound to self-referencing data thanks to the help topic Bind RadTreeView to Self-Referencing Data. My View model exposes a property that I bind to RadTreeView's SelectedItem. When I run the application the setter is not executed.
    In the case of this help example, will SelectedItem be disabled or should I expect it to work?

    Thanks
    Craig
  2. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 23 Oct 2013 Link to this post

    Looking at posts, I've gone down the route of using an IsSelected property and style binding. This has meant I have had to change my OpenAccessORM class which now has a property specific to its presentation in a RadTreeView. 
    I've also had to add code to the XAML code-behind to enable/disable a save button based on the validation of the selection. Then in my View Model on save, I have to search for the selected item in the collection, repeating the selection validation.

    In the XAML I have a text box bound to a property of the SelectedItem which displays the selected item's property value ok.

    So I am unclear why I cannot apply a consistent approach as I have with RadGridView and bind SelectedItem to a property of my View Model and also control the save button IsEnabled state within the View Model based on the selected item's properties.

    Have I compromised the MVVM approach or is there another way?

    Any comments?
    Craig
  3. DevCraft banner
  4. Answer
    Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 25 Oct 2013 Link to this post

    Hi Craig,

    I have created a sample project based on the help article you are referencing. Could you please take a look at the attached project and check whether it is working for your case?
    As far as I understand you would like to select and item in the TreeView using a binding to the SelectedItem property. If that is the case, I hope the sample will be of help to you. Otherwise, could you please modify the sample in order to introduce the issue you are facing or provide us a bit more info about your scenario?

    Regards,
    Hristo
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    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 >>
  5. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 25 Oct 2013 Link to this post

    Hi Hristo
    Thank you for the sample. It works fine.
    I went back through my code and compared the sample with my code. I put back the SelectedItem binding and it works.
    I sorry I can't say why or if there was an error in the code since it has been altered a number of times before to try to resolve it.
    I can only presume there was a coding error.
    Thank you for your help.
    Craig
Back to Top