I have a Window where I have put a Frame. I would like to add a Page to the Frame when I click a button that is also on the Window but not in the Frame. There are several buttons in the Window and each click on a button should load a different Page in the Frame.
Since I'm a total newbie on this WPF stuff it's quite possible that this approach is not the best and I have thought about replacing the Frame with a Canvas and then make UserControls instead of Pages that will be added to the Canvas. I welcome any ideas and suggestions on how to best solve this.
I aiming for a functionality that is similar to the application Billy Hollis demonstrated in dnrtv episode 115. (http://dnrtv.com/default.aspx?showID=115).
Step 1: Create an empty WPF using Visual Studio, enter the name for the application and click on OK. Step 2: Create a button using the following code or drag and drop a button from the ToolBox of Visual Studio 2013.
It is possible and there are various ways of achieving this... If you create a new WPF project in VS it will create a MainWindow. Add a new window, by default it will be called Window1. If you place a button on MainWindow and under the click event of the button put the following code...
The Frame control supports content navigation within content. Frame can be hosted by a root element like Window, NavigationWindow, Page, UserControl, FlowDocument, or as an island within a content tree that belongs to a root element.
NavigationService is for browser navigation within WPF. What you are trying to do is change to a different window TrainingFrm . To go to a different window, you should do this: private void conditioningBtn_Click(object sender, RoutedEventArgs e) { var newForm = new TrainingFrm(); //create your new form.
the Frame class exposes a method named "Navigate" that takes the content you want to show in your frame as parameter. try calling
myFrame.Navigate(myPageObject);
this should work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With