Ticket T446777
Visible to All Users

wizard control - WPF

created 8 years ago

Hello,

We recently updated to 16.1.7 because we wanted to try out the new Wizard control which was added in this version.
Since the documentation for the wizard control are lacking good examples , I am struggling with integrating it using MVVM .

for example, to create a wizard one needs to declare a wizard object and add wizard pages to it. I noticed that the only place to handle Next, Back events is in the wizard object itself and since my pages are basically just user controls and viewmodel classes, I'd like to know if there is a different way I can wire stuff so I can handle the next event in each page since I have special business logic that needs to be executed every time a user transitions from one page to another.

I am attaching a sample project where I've been playing around and trying stuff out. You can see that the core of my logic is in the code behind where I handle the OnNext event and make decision based on user selection.
It would have been much nicer if I can handle it in the viewmodels and pass data between pages somehow.

I'd appreciate any suggestions you might have on how to properly integrate this control

Thank you.

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hi Rem,

You can use the EventToCommand class to process the Next event at the view model level:

XAML
<dxmvvm:Interaction.Behaviors> <dxmvvm:EventToCommand EventName="Next" Command="{Binding ElementName=wizard, Path=SelectedItem.DataContext.NextCommand}" /> </dxmvvm:Interaction.Behaviors>

Alternatively, implement the ISupportWizardNextCommand interface at the view model level.

In the meantime, since you are working with MVVM, there are two ways to determine what page should be displayed next:

  1. Bind Wizard to a collection of view models (see T415475 - How to: Create a wizard based on a collection of view models) and pass the view model to which you wish to navigate to the WizardPage.NextPage property.
  2. Use the WizardService class as demonstrated in the T387258 - How to: Use the WizardService example.

Please let me know if you have any further questions.

Thanks,
Alex

    Comments (3)

      Hi Alex,

      Thank you for your suggestion.
      For some reason the EventToCommand did not work, however, implementing the ISupportWizardNextCommand  worked like a charm.

      Thank you,

        Hi Alex,

        I am having issues with getting the WizardPage.NextPage to work. When I pass in a view model, nothing happens, and the wizard just calls the ToString().

        I was looking at the example and it's quite different from mine. In the example, they bind a list of the same exact view model to item source. My situation is different because I have different types (classes).
        I need to understand how to dynamically navigate to a next page. How does the wizard know which view to display if I only pass the view model.

        can you please provide an example. Feel free to use the sample project I sent you.

        Thanks,

        Andrey K (DevExpress Support) 8 years ago

          Hello,

          I've created a separate ticket on your behalf (T447965: how to dynamically navigate to a next page). It has been placed in our processing queue and will be answered shortly.

          Thanks,
          Andrey

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.