开发者

Mechanism to handle button actions in a 2 page wizard application

I’m creating an application that is in the style of a 2 page wizard. Each wizard page will be a user control which is then used in a single Window used for the entire application. My question is regarding the buttons that I need for each User Control.

The first page will connect to a database and will have a Close button and a Connect button. The Close button will exit the application and the Connect button will carry out some validation. Upon connecting, if there are any errors then the user control will inform he user of this. If there are no errors then the application will need to pass some data to the 2nd user control and then transition to it.

The second page will show the user a summary of tasks that will be carried out and present a Close button which will exit the application and it will also have an Execute button. Clicking Execute will start some long running tasks that update the user control interface. The Close button will become disabled and the Execute button’s text will become a Cancel button which will allow the user to cancel the execution. When the execution completes (either because it is finished or because the user cancelled) then the Close button will re-enable and the Cancel button will change to Finish. Clicking either button at this point will exit the application (although I may later change the behaviour of Finish to do something else before it exits).

Being new to WPF and coming from a WinForms background, I’m not sure of the correct “WPF way” to use these buttons and how they should be w开发者_如何转开发ired up.

My questions are:

  1. Should these buttons be hosted in the user control or on the window outside the user controls?

If hosted in the window:

  1. Currently each user control requires 2 buttons but what happens if this changes in future?
  2. What is the correct mechanism for the button on the window to trigger an action in the user control?
  3. What is the correct mechanism for the user control to change the text or enable/disable of buttons on the window?

If hosted in the user control:

  1. What is the correct mechanism for the user control to notify the window to move to the next page?
  2. This may be the same answer as above, what is the correct mechanism for the user control to notify the window to do something else (e.g. exit the application).

Many thanks in advance.


For a wizard like style you should consider using Pages and handling of navigation by the NavigationService.

You can find more information on this topic by searching google for [wpf page navigation parameter], for example http://www.paulstovell.com/wpf-navigation

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜