I just started programming in my company. Now I try to develop a GUI via WPF in C#. Therefore I want to open a window to select some pdf files. The window has a ListView to display the files, and some filter options.
After selecting a file I want my window to change the whole interface. What is the best option therefore?
Instinctively I choose to copy all my stuff from MainWindow.xaml to MainPage.xaml and also the C# code MainWindow.xaml.cs to MainPage.xaml.cs. On the internet I found some stuff how to do this, but now when it comes to change the interface, I get some trouble. Solutions I found were solutions to use NavigationWindow instead of Window, but I didnt want my GUI to have an option to return to the previous page. So I just gave my MainWindow a Frame, to load my page with frame.Navigate(page).
But dammit, its just same as NavigationWindow. Additionally the objects get kind of ugly, because the MainWindow which loads the pages has an method called UsePage(object page). When I then want to get to the next page, my MainPage has to know either my MainWindow.Frame or the method UsePage to use the next page.
So MainPage : Page Constructor looks something like this:
public MainPage(MainWindow window)
{
InitializeComponent();
this.window = window;
}
and UsePage():
UsePage(Page page)
{
//here some settings for excample to change this.Size when using another page
frame.Navigate(new MainPage(this));
}
So loading next pages works fine, but I alwas get these return buttons:
MainPage: enter image description here (no return key because there is no other page)
ProcessingPage: enter image description here
I just searched all possible methods and parameters in Frame, but didnt got anything to help me... Is there any better way to change a windowstyle than NavigationWindow? I hate to do it this way ^^
Thank you guys in advance ;)
Micha