如何从框架中获取页面实例? [英] How do i get a page instance from a frame?
本文介绍了如何从框架中获取页面实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个在xaml中初始化的帧,如下所示:
I have a frame that i initialized in xaml like this:
<window>
<Frame Name="myframe" NavigationUIVisibility="Hidden" Source="mypage.xaml"/>
</window>
我正在尝试从包含c#代码的框架(依次包含页面)的窗口中获取页面实例,我不知道如何获取它.
I'm trying to get the page instance from the window that contains the frame (which in order contains the page) in c# code and i don't know how to get it.
public partial class mywindow : Window
{
public mywindow()
{
BusinessLogic.Initialize();
InitializeComponent();
var a = myframe.Content;
}
}
我怎么得到它?
谢谢
推荐答案
您的代码是正确的,但是缺少内容的返回.
Your code is correct, but lack cast the return of Content.
public partial class mywindow : Window
{
public mywindow()
{
BusinessLogic.Initialize();
InitializeComponent();
var a = (MyPage)myframe.Content;
}
}
这篇关于如何从框架中获取页面实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文