Passing parameters into ViewModels (Prism)
Posted
by vXtreme
on Stack Overflow
See other posts from Stack Overflow
or by vXtreme
Published on 2010-03-26T15:34:06Z
Indexed on
2010/03/30
17:13 UTC
Read the original article
Hit count: 272
Hi
I can't figure out how to pass parameters to my viewmodels from other views or viewmodels.
For instance, I have a View called Customers. There is a grid inside, and if you double-click the grid, a new view is supposed to come up and allow you to edit that customer's data. But how will the View(Model) responsible for editing data know which customer it's supposed to open if I can't pass any parameters inside?
EventAggregator is out of the question because I obviously can't create hundreds of eventargs, each for one view. And besides, it's a lousy solution.
So far I was able to come up with:
CustomerDataView custView = new CustomerDataView(customerId, currentContext);
manager.Regions[RegionNames.Sidebar].AddAndActivate(custView);
What do you think about this particular solution? Is this the way it's normally done? What I don't like about this is the fact that I lose out on automatic dependency injection by Unity.
© Stack Overflow or respective owner