LoadOnDemand bind the item to an object

4 posts, 1 answers
  1. Mark
    Mark avatar
    50 posts
    Member since:
    Dec 2010

    Posted 01 Sep 2011 Link to this post

    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.



  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 02 Sep 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Mark
    Mark avatar
    50 posts
    Member since:
    Dec 2010

    Posted 04 Sep 2011 Link to this post

    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)


  5. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 07 Sep 2011 Link to this post

    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 >>

Back to Top