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

LoadOnDemand bind the item to an object

3 Answers 57 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 01 Sep 2011, 08:55 AM
I used a custom object to populate the RadTreeView which includes a bool flag that I want to bind to the tree nodes IsLoadOnDemandEnabled property.

The loading of the node is done in the selection change of the VM. After a node is loaded I set the LoadOnDemandEnabled property on the node object. I want to have that property bound to the IsLoadOnDemandEnabled of the tree item.

All the examples get the item in the event and set the property of the RadTreeViewItem. I can acheive this using a message from the VM but I would like to do it via XAML if possible.



3 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 02 Sep 2011, 12:48 PM
Hello Mark,

Please have a look at this help article. It demonstrates the usage of ContainerBindings. Let me know if it helps.

Kind regards,
Kiril Stanoev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Mark
Top achievements
Rank 1
answered on 05 Sep 2011, 04:34 AM
Thanks for the link. I have implemented the suggestions but I still get the expand icon on the lowest level after the node have been added by the LoadOnDemand process. I assume the ContainerBinding should remove this.

<UserControl.Resources>
<telerik:ContainerBindingCollection x:Key="NodeLoadBinding">
<telerik:ContainerBinding Binding="{Binding IsLoadOnDemandEnabled, Mode=TwoWay}" PropertyName="LoadOnDemandEnabled" />
</telerik:ContainerBindingCollection>
</UserControl.Resources>

And the tree
<telerikNavigation:RadTreeView.ItemTemplate>
    <telerik:HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}"
                                                                        telerik:ContainerBinding.ContainerBindings="{StaticResource NodeLoadBinding}">
        <Border Background="{Binding Color}">  
            <TextBlock Text="{Binding NodeLabel}" />
        </Border>
    </telerik:HierarchicalDataTemplate>
</telerikNavigation:RadTreeView.ItemTemplate>

And the VM Code
foreach (lnkProductNodeDB oDB in lTemp)
{
    NewNodes.Add(new gUI.ReportNode(oDB.Product, oDB.NodeKey, oDB, SelectedReportNode,
        "Cornsilk", SelectedReportNode.ChildNodes.Count, false));
}
the final false is the LoadOnDemandEnabled property (it does not implement propertychanged event)


0
Accepted
Kiril Stanoev
Telerik team
answered on 07 Sep 2011, 01:41 PM
Hi Mark,

I did not manage to reproduce the issue. This is a recording of my application which attempts to replicate your scenario. Could you please take a look at the attached application and let me know if I am missing anything. I'd be glad to further assist you.

All the best,
Kiril Stanoev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
TreeView
Asked by
Mark
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or