简体   繁体   中英

How can I reuse the same view with different ViewModel in wpf prism?

I have a View for Insert an entity.

I want to edit the same entity and I want to reuse the same view for edit.

Now, How can I reuse the same view with different ViewModel for edit?

Why do you need two different view models?

  1. Just merge the properties in one viewmodel.
  2. Or better still, break the view into different UserControls for each view model.

I assume you're using the ViewModelLocator , otherwise you wouldn't even have to ask the question.

So drop the view model locator here, navigate to the view model you want ( InsertViewModel or EditViewModel ) and assign the same view to both view models via data template.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM