XAML 框架中的对象和事件范围
我有一个由 5 个“页面”和一个主“页面”组成的程序。一个页面中的事件如何触发其他“页面”中的操作……或者一个“页面”中设置的控制值如何在另一个“页面”中使用?
我已经包含了这样的页面,
<Frame Source="GeneratorPage.xaml" />
我相信这是正确的方法......但我没有运气从这个框架内评估控制。
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));
}
正如您在此处看到的,我创建了模型并将框架导航到我希望显示的页面。但是我的页面如何访问我的模型呢?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不将模型包含在
myPage
类的构造函数中why not include the model in the constructor of your
myPage
class