I am writing an application using Microsoft's Prism framework and I'm having trouble working out the best way to approach a simple 'Save File' style dialog box.
NB: I can't use the standard dialog as I'm not saving files to the file system so need to write something similar from scratch.
So here are the main controls I have for my dialog:
- A user control that shows the hierarchy of folders. (
IFolderView
) - A list view to show the contents of a folder. (
IFolderContentsView
) - A text box for the user to enter the saved files name.
The only real interaction on the form is that when a user selects a folder on the left, the list view on the right gets populated with the folders contents.
When I started writing the dialog I originally created a couple of Regions for my user controls and used view discovery to add my views. I did this because its how I was injecting IFolderView
elsewhere in the application. I now find that I need to know something about the controls in the region for them to interact with each other. I thought about the EventAggregator
but that doesn't seam right for a simple save dialog.
My solution to this problem is to use view injection. So I ask my Unity container for an implementation of the IFolderViewModel
and set its view as the contents of the region during initialization. That way I know enough about the user controls on the form to make it work, but its still all loosely coupled.
Does this sound like a sensible thing to do? Is there a better way? Am I missing something?