oumayma oumayma -4 years ago 176
C# Question

How to open another view

I want to navigate to the next view or to navigate to the previous view after confirmation:

public void Next()
{

MessageBoxResult result = MessageBox.Show("DO YOU WANT TO ENTER WIZARD INSTALLATION PROCEDURE?", "Confirmation", MessageBoxButton.YesNoCancel);
switch (result)
{
case MessageBoxResult.Yes:
wizardAccess wizard = new wizardAccess();
// here I want to pass to another view
break;
case MessageBoxResult.No:
break;
case MessageBoxResult.Cancel:
languageview languageback = new languageview();
// here I want to return to the previous view
break;
}
}

Answer Source

In terms of DevExpress MVVM Framework it should look like this:

[POCOViewModel]
public class ViewModel {
   protected IMessageBoxService MessageBoxService {
       get { return this.GetRequiredService<IMessageBoxService>(); }
   }
   public void Next() {
        var navigationService = this.GetService<INavigationService>();
        var result =  MessageBoxService.ShowMessage(...);
        switch (result) {
            case MessageResult.Yes:
                navigationService.Navigate("NextViewName", ...);
                break;
            case MessageResult.Cancel:
                navigationService.Navigate("PrevViewName", ...);
                break;
        }
    }
}

Take a look at the Services documentation for more details.

The ready to use solution from DX based on the WizardService and the WizardControl is demonstrated here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download