Hello,
I've been using your version of TreeView in my SL application which I want to build using the MVVM pattern. I also need load-on-demand mechanism since I get the children of a TreeViewItem from a WCF service. I read your example about how to do this, but that example uses events in code-behind and as I've mentioned above I want to avoid that by using MVVM. So this is what I did:
(the "i:" namespace is xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity". I added this behavior from Blend 4.)
My main issue is that when I am trying to bind the LoadOnDemand event to the GetChildrenCommand in my ViewModel and I set the CommandParameter using RelativeSource(I want to pass the DataContext of the TreeViewItem so I can get the ID of the expanded item and then call the WCF service which will get the children) what I get as parameter in my Execute method of the command is null.
Is there an issue with RelativeSource binding in this case, or do I need to do something different since I'm using RadControls and not SL toolkit ones.
Also any other solution that could help me achieve the same thing would me much appreciated.
Thanks,
Alex.
I've been using your version of TreeView in my SL application which I want to build using the MVVM pattern. I also need load-on-demand mechanism since I get the children of a TreeViewItem from a WCF service. I read your example about how to do this, but that example uses events in code-behind and as I've mentioned above I want to avoid that by using MVVM. So this is what I did:
<
telerik:RadTreeView
x:Name
=
"radTreeView"
Margin
=
"0"
IsVirtualizing
=
"True"
IsDragDropEnabled
=
"True"
IsLoadOnDemandEnabled
=
"True"
DataContext
=
"{Binding SordsVM}"
ItemsSource
=
"{Binding Children}"
ItemTemplate
=
"{StaticResource SordViewModelTemplate}"
IsEditable
=
"True"
AllowDrop
=
"True"
IsExpandOnDblClickEnabled
=
"False"
IsTextSearchEnabled
=
"False"
>
<
i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"LoadOnDemand"
>
<
i:InvokeCommandAction
Command
=
"{Binding GetChildrenCommand}"
CommandParameter
=
"{Binding RelativeSource={RelativeSource TemplatedParent}}"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
</
telerik:RadTreeView
>
My main issue is that when I am trying to bind the LoadOnDemand event to the GetChildrenCommand in my ViewModel and I set the CommandParameter using RelativeSource(I want to pass the DataContext of the TreeViewItem so I can get the ID of the expanded item and then call the WCF service which will get the children) what I get as parameter in my Execute method of the command is null.
Is there an issue with RelativeSource binding in this case, or do I need to do something different since I'm using RadControls and not SL toolkit ones.
Also any other solution that could help me achieve the same thing would me much appreciated.
Thanks,
Alex.