I am using the RadTreeView control for the first time. I am using the MVVM approach to interact with this control. What I want to do is be able to set and get the SelectedItems of the RadTreeView. I am allowing multiple selections to occur. I have the initial heirarchy list of business objects that I bind to the control. But I can't find a way to neatly interact with a collection of the selected items.
I have read a lot of the various instructions in this area http://www.telerik.com/help/silverlight/radtreeview-how-to-bind-hierarchical-data-use-containerbindingcollection.html. They lead me to using the ContainerBindingCollection and HierarchicalDataTemplate approach. So I have done this, and this is binding my collection of datasource business objects appropriately.
However, this still does not get me exactly what I want. Maybe it is not possible, but what I would like is a way to bind to the SelectedItem property, and receive a collection of selected items; and vice-verca to Set the SelectedItem list, and have the appropriate items selected.
With the way that it is set up using the ContainerBindingCollection approach, I don't see a way to do that...would I have to build my own collection of selected items one-by-one as they select them?
Here is my XAML:
<
telerik:ContainerBindingCollection
x:Name
=
"BindingsCollection"
>
<
telerik:ContainerBinding
PropertyName
=
"IsSelected"
Binding
=
"{Binding IsSelected, Mode=TwoWay}"
></
telerik:ContainerBinding
>
</
telerik:ContainerBindingCollection
>
<
telerik:RadTreeView
Margin
=
"0, 20, 0, 20"
SelectionMode
=
"{Binding SelectionMode}"
ItemsSource
=
"{Binding SortedTableOfContentsList}"
SelectedItem
=
"{Binding SelectedPage, Mode=TwoWay}"
>
<
telerik:RadTreeView.ItemTemplate
>
<
telerik:HierarchicalDataTemplate
ItemsSource
=
"{Binding RelatedPages}"
telerik:ContainerBinding.ContainerBindings
=
"{StaticResource BindingsCollection}"
>
<
StackPanel
Orientation
=
"Vertical"
VerticalAlignment
=
"Bottom"
>
<
TextBlock
Text
=
"{Binding Description}"
></
TextBlock
>
<
TextBlock
FontSize
=
"9"
Text
=
"{Binding Notes}"
Margin
=
"10, 0, 0, 0"
></
TextBlock
>
</
StackPanel
>
</
telerik:HierarchicalDataTemplate
>
</
telerik:RadTreeView.ItemTemplate
>
</
telerik:RadTreeView
>
Notes: I do get all my heirarchy items to show in my tree list appropriately. I do have an "IsSelected" property added to my business object for binding. I am getting my "SelectedPage" property to fire in my view model for each item that is selected...it just fires one at a time as items are selected individually.
Thanks!
Stacey