开发向导用户界面 - WPF [英] Developing wizard UI - WPF

查看:963
本文介绍了开发向导用户界面 - WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有WPF:

开发一个向导应用程序,用户必须回答一些带到主应用程序之前简单的问题。主要的应用程序,然后与从向导获得的信息预填。

Developing a wizard application, user has to answer a number of simple questions before brought to the main app. The main app is then prefilled with the information obtained from the wizard.

我开始了一个窗口,然后我计划增加用户控件来。主窗口将有第一行中的用户控件,然后单击Next和Previous按钮来控制第二行中的控件之间移动。这样我可以很容易地控制逻辑,像屏幕之间切换:

I started with a Window which I then planned to add usercontrols to. The main window would have the user control in the first row, then Next and Previous buttons to control moving between the controls in the second row. This way I could easily control the logic to switch between screens like:

WizardControl1.IsVisible = false;
WizardControl2.IsVisible = true;



但出于某种原因,用户控件没有制定者可见性。华友世纪。

But for some reason, user controls do not have setter for IsVisible. Hurray.

于是我想我会只使用单独的窗口为向导的每个部分。这种方法的问题是,现在的步进时,该窗口在随机位置打开,并通过steppign通过与下一个向导,在下一个窗口中随机弹出这实在是分散和沮丧。

So then I thought I would just use seperate windows for each section of the wizard. The problem with this approach is that now when stepping between, the window opens in random positions, and by steppign through the wizard with next, the next window pops up randomly which is really distracting and frustrating.

所以,我怎么能正确地制定一个向导?我不明白这是为什么这么难?不正是火箭科学...替换文本和控件并按下一首/上!

So how can I develop a wizard properly? I don't get why this is so hard...not exactly rocket science... replacing text and controls and storing input after pressing next/previous!

感谢

推荐答案

我可能会的形式给出这个使用数据绑定和模板选择。有向导的形式绑定到一个WizardData类,它暴露了WizardPage基类的列表。

I'd probably aproach this using data binding and template selectors. Have the wizard form bind to a "WizardData" class, which exposes a list of "WizardPage" base classes.

WizardData类可以公开属性定义的正确信息表格,并显示该使用模板选择确定适当控制基础上的实际类型的特定向导页显示在主页的控制。

The WizardData class can expose properties defining the correct info on the forms, and display a control for the main page that uses a template selector to determine the proper control to display based on the actual type of the particular wizard page.

这听起来希望更多的工作是,真的。它也给你的代码和UI(所有工作是由WizardData和WizardPage类完成),并测试逻辑独立的UI的能力之间的良好分离的好处。

It sounds like more work than it is, really. It also gives you the benefit of good separation between code and UI (all "work" is done by the WizardData and WizardPage classes), and the ability to test logic independent of the UI.

这也是接近问题的一个非常WPF / MVVM方式。

It's also a very WPF/MVVM way of approaching the problem.

这篇关于开发向导用户界面 - WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆