Reputation: 700
I have a program which is made up of 5 "pages" and a main "page". How can events in one page trigger actions in other "pages"... or a control value set in one "page" be used in another "page"?
I have included the pages like this
<Frame Source="GeneratorPage.xaml" />
Which I believe is the correct way... but I have had no luck assessing controls from within this frame outside it.
public partial class MainWindow : Window
{
Model myModel;
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
myModel = new Model();
mainFrame.Navigate(new Uri(@"\myPage.xaml",UriKind.Relative));
}
As you can see here I create my model and navigate my frame to the page I wish to display. But how can my page access my model?
Upvotes: 1
Views: 317
Reputation: 20471
why not include the model in the constructor of your myPage
class
mainFrame.Navigate(new myPage(myModel));
Upvotes: 1