Trying to make a document viewer, like Acrobat, which consists of pages, and each page consists of thumbnail images (of varying sizes at users discretion). I’m not sure how to design the MVVM.
At the moment I have:
DocumentViewModel, PageViewModel, ThumbnailViewModel
DocumentViewModel has ObservableCollection() // keeps track of Pages
PageViewModel has ObservableCollection() // keeps track of thumbnails to be displayed by document.
However this design causes problems. For example, if there are 3 pages of thumbnails. And half of the thumbnails are removed from page 2, then page 3 thumbnails should automatically relocate to the newly available space on page 2. Each PageViewModel would have to have awareness about each other, which would be breaking the MVVM policies, no? Would it be better to have the 2 ObservableCollections, declared within DocumentViewModel?
Any help, pointers, advice, guidance welcomed.
Solved! i’m using both helgeheldre’s suggestion of using the DocumentViewModel as the controller and Jen H’s suggestion of using Caliburn.Micro’s Framework for messaging.
All messages get routed to the DocumentViewModel (Via EventAgregator), who then delegates tasks to individual PageViewModels.