© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
108 replies
stigzler

✅ WPF - how to approach a treeview displaying different types at different levels via MVVM

I'm just learning WPF - so seeking some design advice. I'm designing a Visual Studio extension to view and edit Gists. Each type Gist has a collection of type GistFiles (Files property in a Gist):

I'll have 3 views inside the main View: GistsBrowser (user control=treeview), GistEditor (user control) and GistFileEditor (user control). I'm thinking I need to store the Collection of Gists in the MainViewModel, as different UserControls/ViewModels will need access to a shared GistsCollection to ensure synchronicity.

For the GistsBrowser, I need to make a specific treeview control to display all Gists at the root level which can be expanded to show all of the GistFiles within a Gist. There will be no further child levels.

Thus, this UserControl will need its own ViewModel (GistsBrowserViewModel). However, I'm stuck on a few things:

How to structure the Gists collection in MainViewModel. Not sure if I need to map the Github data objects onto my own models, or map them directly onto a viewmodel. Do I need a Gist/GistFile viewmodel? Also, this links with:
What data construct to use for the Gists collection and how to hook it up to a TreeView (given level 0 will be Gists and level 1 GistFiles)

I hope that makes some kind of sense. Any pointers for further reading/research would be appreciated.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

✅ Correct MVVM approach for displaying models representing settings
C#CC# / help
3y ago
WPF Question MVVM
C#CC# / help
2y ago
WPF TreeView Fails to load ItemsSource
C#CC# / help
16mo ago
how would you implement a treeview of a directory with mvvm patterns 🤨
C#CC# / help
4y ago