michaelscodingspot / WPF_MVVMC

A WPF framework for navigation between pages with MVC-like pattern
MIT License
64 stars 18 forks source link

SOLVED: How to get model data from code behind of step? #15

Closed papillon2k2 closed 1 year ago

papillon2k2 commented 1 year ago

Hi, thanks for this package.

How can I access the model from the code behind of one of the steps? Specifically in the last step, I have a button and I want to get model's data from the button OnClick() event handler.

Thanks

UPDATE - ok sorry, it was simple, I found it, I just updated the viewmodel from the model (in viewmodel's constructor), then accessed the viewmodel from code behind taking it from the controller's DataContext: FourthStepViewModel viewModel = this.DataContext as FourthStepViewModel; var st = viewModel.something;

Marking the issue as solved.

michaelscodingspot commented 1 year ago

All right, I’m glad you solve it.