Reputation: 31
What is the best way to add user defined data to a ViewModel at design time?
At runtime I want to display a subset of ViewModels for a class that don't require a root element. To do this at the moment I am tagging the ViewModels at design time by creating a ViewModel variable and assign it an intialvalue and using it as follows:
ViewModelUserControl vmc = new ViewModelUserControl();
vmc.ViewModelName = name;
vmc.SetEcoSpace(ecoSpace);
string vmTitle = vmc.ViewModel.ViewModelVariables
.Find(x =>x.Name=="vmUserTitle")?.InitialValue ?? "";
if (vmTitle != "")
{
...display and do stuff with the ViewModel...
Is there a better way?
Upvotes: 1
Views: 39
Reputation: 2435
ViewModels can have TaggedValues, on all levels. I would use that instead of a variable defintion.
Upvotes: 1