0

I'm very new to WPF. I have to create an WPF app which will do the following:

1) User can change the UI at run time. Controls in each UI are fixed. Suppose two textboxes for numeric value accept and command button to perform multiplication operation and alert the result.

2) Most importantly user can browse the folder of XAML files (UI) and select them / change then at run time. There can be 'n' number of UI users can create and use.

3) I want to use MVVM pattern.

I found this as best example but with doubt. Doubt is that, can user browse user controls and select then, set them? Do they need to be created and added to list before build see this ?

Which is the best way to achieve this task?

Community
  • 1
  • 1
waghekapil
  • 321
  • 1
  • 5
  • 22
  • *user can browse the folder of XAML files (UI) and select them / change then at run time.* that sounds weird. It's in no way normal, that's for sure. So whatever you do will probably not fit well in the traditional sense of the mvvm pattern. So use it where you can, and work around it where you can't. –  Jul 18 '16 at 13:50

1 Answers1

0

If you follow the MVVM pattern, you should create a View (implemented by an User Control) for each UI that your user selects. The Main View will have a ContentControl (or another control type that can host user controls like a HeaderedContentControl) which can host the other Views that the user selects. The view changes will be performed by the associated view model, just like the example you gave.

Trying to answer your question, you should create a menu where the user can select the View to be displayed. The existing views don't need to be added to a list before, because they will already exist in your project. If you want a more detailed example, with code, just update your question with some example you want, like the user can select two views from a menu for instance, and I will add some code .

Henrique Forlani
  • 1,325
  • 9
  • 22