开发者

C# WPF Multi Display

Alright so doing some WPF programming, which I don't do often... And I need to have like, on the main page I have 2 buttons, and each button is going to hide the main page and display a different page of controls.

I'm currently using ContentControl, and showing/hiding them as needed. And it's starting to get messy. And I'm sure there's a better way to do this.

So... Suggestio开发者_JAVA技巧ns =]?

EDIT: Sorry about it being vague, what I currently have is 2 buttons in a ContentControl, when clicking one of the buttons it hides that ContentControl, and shows a different ContentControl, with its own set of controls, and a back button. When clicking that back button it hides the current ContentControl, and shows the original. And this is getting messy, so im looking for a better method of doing this.


I suggest you take a look at some MVC type of framework. They are design pattern solutions for problems just like the one you are describing.

The framework that I like most, because it's simple to understand and learning curve is not so steep is the MVVM Light Toolkit, but there is also PRISM and Caliburn.

They might seem a little bit more complicated, but the clarity and organization it promotes in your code will pay off in the end.


Your question is rather vague.

You should probably make two user controls and hide/show them when clicking the buttons.


That navigation concept is generally known a "Wizard". There are several wizard controls that you can use. There are several vendors with commercial WPF wizard controls, as well as several free versions, such as here and here.

This is a related question, also.


Because what you are doing is limited in design, why not go with a DataTemplateSelector.

Based off the datacontext you can switch out the xaml being used.

MSDN: DataTemplateSelector Class

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜