[英]Using Frame.Navigate with typeof(UserControl)
It is possible to do so? 有可能这样做吗? Do I need to use only
Page
objects instead? 我只需要使用
Page
对象吗? I've tried to Navigate
to a UserControl
and I get: 我试图
Navigate
到UserControl
,我得到:
Exception thrown: 'System.NullReferenceException' in Project.exe
抛出异常:Project.exe中的“System.NullReferenceException”
Object reference not set to an instance of an object.
你调用的对象是空的。 at Windows.UI.Xaml.Controls.Frame.Navigate(Type sourcePageType)
在Windows.UI.Xaml.Controls.Frame.Navigate(类型sourcePageType)
However, if I use a Page
, it works perfectly. 但是,如果我使用
Page
,它就可以完美运行。
I posed an entire project using UserControls and I'm afraid I will have to outline it back :( 我使用UserControls构建了一个完整的项目,我担心我将不得不回顾它:(
The Frame.Navigate()
methods description it says for it's first parameter Frame.Navigate()
方法描述它说的第一个参数
The page to navigate to, specified as a type reference to its partial class type.
要导航到的页面 ,指定为其部分类类型的类型引用。 (A type reference is given as System.Type for .NET, or a TypeName helper struct for C++/CX)
(类型引用为.NET的System.Type或C ++ / CX的TypeName帮助器结构)
So I'm sorry, but you need a Page
or a class derived from the Page
for navigation 所以我很抱歉,但你需要一个
Page
或一个派生自Page
的类来导航
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.