gpt4 book ai didi

c# - 将 `Page` 替换为 `WinRTXamlToolkit.Controls.AlternativePage`

转载 作者:太空宇宙 更新时间:2023-11-03 11:05:15 24 4
gpt4 key购买 nike

我正在尝试使用 Windows RT XAML Toolkit这样我就可以访问 TreeView 控件。我创建了一个新的 BlankApp,其中包含一个包含 XAML 的 MainPage,与此类似:

<Page
x:Class="BlankApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BlankApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

</Grid>
</Page>

我想将此 Page 更改为 WinRTXamlToolkit.Controls.AlternativePage。我已将 XAML 修改为:

<xc:AlternativePage
x:Class="BlankApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xc="using:WinRTXamlToolkit.Controls"
xmlns:local="using:BlankApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

</Grid>
</xc:AlternativePage>

并修改了 MainPage 类以扩展 WinRTXamlToolkit.Controls.AlternativePage 而不是 Page

现在,当我启动我的应用程序时,它会在以下语句中失败:

        if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}

我收到“无法创建初始页面”,但没有收到更多详细信息。

所以我的问题是:1. 如何找到有关 Navigate 调用失败原因的更多详细信息?我尝试添加 rootFrame.NavigationFailed += rootFrame_NavigationFailed;,但似乎没有引发导航失败事件。2. 如何正确使用WinRTXamlToolkit.Controls.AlternativePage页面?

最佳答案

您是否进行了使用替代页面所需的其余更改?

查看 SDK 中的示例代码。具体在这里:

http://winrtxamltoolkit.codeplex.com/SourceControl/changeset/view/379f4af0e5862131aea1992f6875180abeddbcb6#WinRTXamlToolkit.Sample/AppShell.xaml.cs

public sealed partial class AppShell : UserControl
{
public static AlternativeFrame Frame { get; private set; }

public AppShell()
{
this.InitializeComponent();
Frame = this.RootFrame;
this.RootFrame.Navigate(typeof (MainPage));
}
}

关于c# - 将 `Page` 替换为 `WinRTXamlToolkit.Controls.AlternativePage`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16131740/

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