gpt4 book ai didi

c# - 使用 Frame.Navigate 和 typeof(UserControl)

转载 作者:太空宇宙 更新时间:2023-11-03 23:25:57 25 4
gpt4 key购买 nike

有可能吗?我是否需要仅使用 Page 对象?我试图导航到一个UserControl,我得到:

Exception thrown: 'System.NullReferenceException' in Project.exe

Object reference not set to an instance of an object. at Windows.UI.Xaml.Controls.Frame.Navigate(Type sourcePageType)

但是,如果我使用 Page,它会完美运行。

我使用 UserControls 提出了整个项目,恐怕我将不得不重新概述它:(

最佳答案

第一个参数的 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)

很抱歉,您需要一个Page 或从Page 派生的类进行导航

关于c# - 使用 Frame.Navigate 和 typeof(UserControl),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33806099/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com