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
case MessageBoxResult.No:
case MessageBoxResult.Cancel:
languageview languageback = new languageview();
// here I want to return to the previous view

Answer Source

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

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", ...);
            case MessageResult.Cancel:
                navigationService.Navigate("PrevViewName", ...);

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