Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

MVVM - TreeView - Workspaces - Memory Management

$
0
0

In my app, I have a main page with a TreeView. Select the edit button next to an item in the tree and you get a window where it can be edited.  Some items have subitems that are, themselves, displayed in the TreeView.  Details edited at the node level (namely, the display name) automatically adjust themselves in the Tree.  But if I add a child in the editing workspace, the Tree doesn't get that object added.  I understand why this happening and I'm trying to fix it.

In my scenario, clients have plans...  The tree uses a TreeViewClientViewModel which has a collection of TreeViewPlanViewModels.  If I click the node to edit the client, the underlying client entity is passed to a ClientViewModel attached to the workspace.  The ClientViewModel creates a collection of PlanViewModels from the client entity (calling to get them populated if the treeview node hadn't been expanded) to display in a DataGrid in the workspace.  If I add a plan, I create a new plan entity and add stuff it into a new PlanViewModel and add it to the collection.  The workspace updates properly, but since the TreeViewClientViewModel has no knowledge of the PlanViewModel collection, it doesn't reflect the changes.

Do I create a single ViewModel class that is shared by the TreeView and Workspace, despite the fact the Views have very different interactions and needs?

What's the best approach, here?

Also, how do I manage memory?  I suppose it's possible that user could go down and expand every tree node and call to edit every node, essentially calling every object in the database into local memory...  How do I manage that?  Or do I even need to?

Thanks.

J


http://digitalcamel.blogspot.com/


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>