I have multiple of views (user controls), each with its own ViewModel
. To navigate between them I am using buttons. Buttons display image and text from corresponding view model and also need column and row (because there are like 10 views: 10 columns with different number of rows each).
Right now buttons are created dynamically (I made a Navigator
control for this) and for view models I have base class to hold text, image, column and row. Number of views available will be different (depends on user level and certain settings), that's why it's I need control here.
Question: how shall my control get data from view models?
Right now I have interface INavigator
, defined in (lol) control itself. And view models implement it. I could go opposite, let my control to know about view models. Both looks wrong.
There is a single Navigator
control what has, lets say, Items
bound to a list of view models. It can cast each view model to INavigator
or ViewModelBase
(common for all pages) to obtain specific view model image, text, column and row. So either view model knows about control (to implement INavigator
) or control knows about ViewModelBase
.. And this is a problem, both solution bind tight control and view models, which is bad in mvvm
.
Schematically