Creating a Page in the Code Behind at Run-time
-
19-04-2021 - |
Question
I'm reading about the WPF Navigation Services and I have a general question.
At run-time I want to be able to parse an external XML file that has information about an UI (i.e. a series of screens) and then in the code-behind create a WPF Navigation service with multiple Pages. Is it possible to create a new WPF Page at run-time or do they have to be created in Visual Studio first?
Thanks Mike
La solution
You can create a new page in the code behind. All you need is a frame to add it to
Page page = new Page();
MainFrame.Navigate(page); // MainFrame is the x:Name of the Frame within XAML
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow