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

LoadOnDemand force notification for IsLoadOnDemandEnabled

1 Answer 72 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 2
Shawn asked on 07 Feb 2019, 07:15 PM

I am trying to use a TreeView to show data read from a webservice.  However, I have a special requirement.  Normally the presence of the ExpandCollapseIndicator is determined by the return value of CanExecute function of the LoadOnDemandCommand.  A custom item template would include the ExpandCollapseIndicator and bind its IsLoadOnDemandEnabledProperty to TreeViewDataItem.IsLoadOnDemandEnabled.  This works fine if the ability to expand/collapse remains constant. I need the ability to change the value of TreeViewDataItem.IsLoadOnDemandEnabled AFTER the tree node has been initialized.  Normally, I would just do OnPropertyChanged(nameof(IsLoadOnDemandEnabled)) but I do not have access to that since TreeViewDataItem is a wrapper around my own data model class.  I do not have access to TreeViewDataItem.

 

So how can I force an update to the ExpandCollapseIndicator AFTER the tree node has been initialized as my CanExecute function of LoadOnDemandCommand will now return a different value?

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 12 Feb 2019, 01:26 PM
Hi Shawn,

Thank you for providing the scenario details.

Would it possible, in this case, to add a boolean property to your business object indicating whether load-on-demand should be enabled for this item?  Using this property you could switch the TreeViewItem IsLoadOnDemandEnabled value through binding inside the TreeView ItemTemplate.

What do you think of such an approach, would it work for you?

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
Shawn
Top achievements
Rank 2
Answers by
Yana
Telerik team
Share this question
or