简体   繁体   中英

User Controls and Windows in WPF

I am making a wpf application. I am very new to WPF. I have a main layout screen which has a background content and other screens that have the layout plus some more controls exclusive to those screens.

I am doing it as:

The main layout screen is a Window and the other dedicated screens are user controls.

For every specialized screen, I am doing this:

Application.Current.MainWindow mw;
mw.Content = nameOfCurrentUserControl;

Is this idea fine?

If I understand correctly you want to have a program with different pages. Like a wizard for instalation.

Then what you want to do is to create a Window (as you did) and inside it add a Frame . Then you create Pages and in each page you create the layout you want.

Then in your main Window, you create instances of your Pages (mySecondPage = new SecondPage()) and then you Navigate from one page to the other loading them into the frame of the main Window using MyFrame.Navigate(mySecondPage)

Here you have much more information about navigation : http://paulstovell.com/blog/wpf-navigation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM