How to have duplicate model/view-model in TabControl
-
I have a view which populates tab controls as follows:
The above has been simplified for clarity. What I want is two instances of the LogFileViewModel and LogFileView pair in the tab, one for video files and one for RFID files. However, the above does not allow me to have the same model class twice, for reasons that are fairly obvious. I have got round this by deriving classes from LogFileViewModel, called VideoLogFileViewModel and RfidLogFileViewModel, which initialise the base class appropriately. The tab control obtains the view model instances from the ViewModels property of the main view model. Hence my workaround makes sure that there are no duplicate view model class instances. However, it is inelegant. Is there some more elegant way of doing this? I was wondering is there is some jiggery pokery I can add to the to allow it to identify a specific instance of LogFileViewModel i.e. to compare a string property with a fixed value.
-
I have a view which populates tab controls as follows:
The above has been simplified for clarity. What I want is two instances of the LogFileViewModel and LogFileView pair in the tab, one for video files and one for RFID files. However, the above does not allow me to have the same model class twice, for reasons that are fairly obvious. I have got round this by deriving classes from LogFileViewModel, called VideoLogFileViewModel and RfidLogFileViewModel, which initialise the base class appropriately. The tab control obtains the view model instances from the ViewModels property of the main view model. Hence my workaround makes sure that there are no duplicate view model class instances. However, it is inelegant. Is there some more elegant way of doing this? I was wondering is there is some jiggery pokery I can add to the to allow it to identify a specific instance of LogFileViewModel i.e. to compare a string property with a fixed value.
-
Thanks Pete This is probably ignorance on my part but I'm not sure how that would work with my case, since I want two instances of the same template visible at the same time, or more precisely, present at the same time since you can only view one tab at any given time. I need to think about this more!
-
Thanks Pete This is probably ignorance on my part but I'm not sure how that would work with my case, since I want two instances of the same template visible at the same time, or more precisely, present at the same time since you can only view one tab at any given time. I need to think about this more!
You're using two separate ViewModel instances - the appropriate template will be rendered in place based off the ControlTemplate.
This space for rent