1

I am designing a WPF C# .net 4.5 application currently.

I would like the application to have 2 user interfaces:

Simple, and Advanced. I am sure you get the idea. They will be quite different in terms of layout, but similar functionality.

How would people recommend approaching this?

I have thought of two ways but not sure on the practicalities:

1. I currently have a Mainwindow.xaml main UI, and much of the logic in the codebehind of that file. Could you have two separate 'layouts' in the xaml of that MainWindow.xaml. Not sure what logic would be used to choose which one?

2. A Mainwindow1.xaml, and MainWindow2.xaml type approach, where you have two different windows. The problem I see if that much of the program logic I have already produced is on behind the MainWindow.xaml page, so this would need to be separated somehow to there own 'processing' classes. The opening window can be defined in the app.xaml.cs file on load?

Any other suggestions, most welcome..

3
  • 2
    have a look at the MVVM pattern. You could have a single view model (where you logic resides) interact with several Views (a detailed and advanced). So you don't have to duplicate business logic for two "main windows" Commented Jan 15, 2015 at 22:08
  • It really depends how different the 2 views are going to be with regards to whether you separate them or manage them in the one view. For example, if there were a few buttons and options missing, I would bind their Visibility to a bool IsAdvancedMode on the view model (using a converter to convert True into Visible and False into Collapsed). You could probably get away with hiding a lot of your advanced mode elements like this if your xaml is well laid out and panels used well. Either way, a view model approach is the best way to deal with this, regardless of whether views are split or not. Commented Jan 15, 2015 at 22:22
  • I think the layout will be quiet different, perhaps the simple view is a 800x600 fixed window, and the advanced view a resizeable window for example. Commented Jan 15, 2015 at 22:56

1 Answer 1

2

Stop using code behind. Your whole approach is wrong. WPF is designed for model-viewmodel-view design pattern, in short mvvm, this means the model is doing for example calulations or some logic and return results. Then you have the viewmodel which controls how to transfer the data into the view and from the view. And then you have the view which is how you represent the data in the UI. In your case you will have 2 different views. And you will need to implment your logic once

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.