Reputation: 246
I am using MVC in Windows Forms. I have a question regarding wizards/dialogs/error_msgs in MVC that is where should I call the wizards/dialogs/error_msgs
i. show from controller
ii. notify the view from controller to show dialogs/wizards/error_msg
Which approach is correct?
class Controller
{
IView view;
public void DoSomthing()
{
// i) approach
Wizard wz = new Wizard();
wz.Show();
MessageBox.Show("Error while DoSomething");
// ii) approach
view.ShowWizard();
view.ShowErrorBox();
}
}
Upvotes: 0
Views: 121
Reputation: 3061
Although I agree with @StealthRabbi's comment, you should be more specific, and explain what is wizards/dialogs/erros_msgs
, from your code I assume, you want to know, whether you should directly create and show Wizard
window from controller
or ask view
to show it.
Clearly the answer is ii)
option, all UI related stuff should be done by view
. Showing Wizard
window is UI related stuff, so controller
shouldn't directly create Wizard
, but rather ask view
to do that. So your code should go like this
class Controller
{
IView view;
public void DoSomthing()
{
// ii) approach
view.ShowWizard();
view.ShowErrorBox();
}
}
Upvotes: 1