I'm not currently somewhere I can test this, but I'd approach it by inheriting a base TileViewModel
(or Tile
) in all my ViewModels
(although you'd probably also define an ITile interface). This could contain the Tile
position information, display size, and other common Tile
behaviour.
On the main control hosting your tiles, you could then maintain a collection of Tile
objects, and every time you want to add a new Tile
and display it, you could add your new ViewModel
instance to the collection of Tiles
and call the Caliburn.Micro
Activate
method on the new instance. Off the top of my head, I think you'd need to change your DataTemplate
so the cal:View.Model
property bound to the object directly, rather than a property, so something like cal:View.Model="{Binding}"
Caliburn.Micro
should take care of ViewModel
/View
resolution for each of those tiles, using the built in conventions. You would have to make the hosting control Conductor<IScreen>.Collection.AllActive
to allow all of the Tiles
to be active at once.
Another property that might be of interest in this particular situation, is the cal:View.Context
property, which will allow you to have multiple Views
over the same ViewModel
. So each of your Tiles
could support different Views
to provide different information (or functionality). It's mentioned briefly in the documentation, and I had a crack at explaining the convention: One ViewModel, multiple views.
I'll try and test my above suggestion, when I get a chance, to see if it's viable.