We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Handle LoadOnDemand using Prism

Hi,

what would be an elegant way to handle the LoadOnDemand without using Code Behind?

I am currently using an Eventtrigger
      
and then i have:

  class OnDemandLoading:TargetedTriggerAction
  {
    protected override void Invoke(object parameter)
    {
      TreeViewItemAdv item = (parameter as LoadonDemandEventArgs).TreeViewItem;
      TreeviewViewModel data = new TreeviewViewModel();
      data.OnDemandLoad(item);
    }
  }

It is working, but my problem is that i always need to create a new instance of my ViewModel, since i have no idea, where i came from.

10 Replies

SS Susmitha Sundar Syncfusion Team June 17, 2019 02:40 PM UTC

Hi Helmut, 

Thank you for contacting Syncfusion support. 

Currently, we are analyzing your requirement of “Handle the OnLoadDemand using prism in TreeViewAdv”. We will validate and update you the details in two business days (June 19, 2019). We appreciate your patience until then. 
 
Regards, 
Susmitha S

 



SS Susmitha Sundar Syncfusion Team June 19, 2019 04:29 PM UTC

Hi Helmut, 
 
Thank you for your patience. 
 
Based on your requirement, we have prepared the sample with TreeViewAdv OnDemandLoading using EventTrigger. We use the command binding in ViewModel class. Please refer the below sample, 
 
 
But we suspect, you create a separate class for OnDemandLoading and try to get the ViewModel from this class. If so, you should create an instance for ViewModel or use MainView DataContext. Please refer the following code snippet for this, 
 
C#: 
MainWindow mainWindow = new MainWindow(); 
 
(mainWindow.DataContext as ViewModel).TreeItems 
 
Please check the sample and let us know. If we misunderstood, please modify the sample based on your scenario and revert us back with the following detail, 
  • Syncfusion Essential studio version
It will be helpful for us to check on it and provide you the solution at the earliest.   
 
Regards, 
Susmitha S 



HW Helmut Wahrmann June 20, 2019 10:01 AM UTC

Hi Susmitha,

thanks a lot for your reply. The trick with the MouseClick in the Eventtrigger did it.
I am landing in my ViewModel now, instead of a separate class and can now do what i want.
i have modified your example and attached it as a reference.
in fact i want to build a directory tree by loading thze dub folders on demand, when the user clicks on it.

thanks,

Helmut

Attachment: TreeViewAdv_WPF_New_b3a38d10.zip


SP Subburaj Pandian Veluchamy Syncfusion Team June 21, 2019 12:26 PM UTC

Hi Helmut, 
  
Thank you for your update. 
  
We have analyzed your modified sample. In this sample, you already loaded the directory items by OnLoadDemand when expand the TreeNodes. 
  
Can you please provide more information about your requirement, it will be helpful for further analysis? since the shared information not enough to understand clearly. 
 
Regards,
Subburaj Pandian V  



HW Helmut Wahrmann June 22, 2019 07:51 AM UTC

Hi Susmitha,

yes, doing that now. 
With your help before, i am not invoking an action in a separate class, where i wouldn't be able to get a reference to the view model.
Instead of that i am using your method of invoking the command in my viewmodel.

the problem is solved for me.
I was just attaching my version of the program as a reference.

thanks for your help.

Helmut


HW Helmut Wahrmann June 22, 2019 09:08 AM UTC

Hi Susmitha,

one additional question that now comes up.
Let's assume a user selected now some sub folder in the treeview and i want to expand the treeview on the next program start to show this sub folder.

As i am dynamically loading the folders into the tree, i can't traverse in the startup of the viewmodel.

How would i select a sub folder in this scenario?

thx,

Helmut


JP Jagadeesan Pichaimuthu Syncfusion Team June 24, 2019 12:02 PM UTC

Hi Helmut, 
  
Thank you for your update. 
  
Based on the provided information, we suspect you need the following requirement, 
  
•    Run the application. Expand any subfolder. 
•    Close the application. Again run the application. 
•    That Expanded subfolder need to be expanded state. 
  
Can you please confirm on this and let us know? It will be helpful for our further analysis. 
  
Regards, 
Jagadeesan 



HW Helmut Wahrmann July 6, 2019 04:52 PM UTC

Hi Jagadeesan,

correct, the last displayed sub folder, before the app was closed should be displayed again.

regards,

Helmut


SP Subburaj Pandian Veluchamy Syncfusion Team July 8, 2019 01:01 PM UTC

Hi Helmut, 
  
Thank you for the update. 
  
As per your requirement, the nodes should be saved in local storage and need to be display. So, we are currently checking the feasibility of this. We will let you know the complete details of this requirement on or before July 10, 2019. We appreciate your patience until then. 
 
Regards,
Subburaj Pandian V   



SP Subburaj Pandian Veluchamy Syncfusion Team July 10, 2019 01:33 PM UTC

Hi Helmut, 
  
Thank you for your patience. 
  
We have analyzed and considered your requirement of “TreeViewAdv nodes need to be serialized in local storage when close the application” and logged feature request for the same. We will implement this feature in any of our upcoming release. 
  
At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented. We appreciate your patience until then. 
  
Thank you for requesting this feature and helping us define it. We are always trying to make our products better and feature requests like yours are a key part of our product growth efforts. 
  
You can also communicate with us regarding the open features any time using our Feature Report page.  
  
  
If you have any more specification/suggestions to the feature request, you can add it as a comment in the portal and cast your vote to make it count. 
 
Regards,
Subburaj Pandian V 


Loader.
Up arrow icon