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

SelectedItem binding with self-reference example

3 Answers 101 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 22 Oct 2013, 04:31 PM
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

3 Answers, 1 is accepted

Sort by
0
Craig
Top achievements
Rank 1
answered on 23 Oct 2013, 10:22 AM
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
0
Accepted
Hristo
Telerik team
answered on 25 Oct 2013, 08:08 AM
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 >>
0
Craig
Top achievements
Rank 1
answered on 25 Oct 2013, 10:54 AM
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
Tags
TreeView
Asked by
Craig
Top achievements
Rank 1
Answers by
Craig
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or