用`WinRTXamlToolkit.Controls.AlternativePage`替换`Page` [英] Replace `Page` with `WinRTXamlToolkit.Controls.AlternativePage`

查看:151
本文介绍了用`WinRTXamlToolkit.Controls.AlternativePage`替换`Page`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用的Windows RT XAML工具包,这样我可以有机会获得 TreeView控件控制。我创建了一个包含含XAML类似下面的的MainPage新BlankApp:

I'm attempting to use Windows RT XAML Toolkit so that I can have access to the TreeView control. I've created a new BlankApp that contains a MainPage containing XAML similar to this:

<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>



我想改变这种来的 WinRTXamlToolkit.Controls.AlternativePage 。我已经修改了XAML是:

I want to change this Page to an WinRTXamlToolkit.Controls.AlternativePage. I've modified the XAML to be:

<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 ,而不是

And modified the MainPage class to extend WinRTXamlToolkit.Controls.AlternativePage rather than Page.

现在,当我启动我的应用程序,它没有在下面的语句:

Now when I launch my app, It fails in the following statement:

        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");
            }
        }



我收到无法创建初始页,但不是更多的细节。

I receive the "Failed to create initial page", but not more details.

所以我的问题是:
1.我如何才能找到更多的细节,为什么导航呼叫失败的原因?我尝试添加 rootFrame.NavigationFailed + = rootFrame_NavigationFailed; ,但似乎导航失败事件并没有越来越提高。
2.如何正确使用 WinRTXamlToolkit.Controls.AlternativePage 页?

So my questions would be: 1. How can I find out more details on why the Navigate call is failing? I tried adding rootFrame.NavigationFailed += rootFrame_NavigationFailed;, but the navigation failed event does not seem to be getting raised. 2. How can I properly use the WinRTXamlToolkit.Controls.AlternativePage page?

推荐答案

你做的使用替代页面所需其余的改动?

Did you do the rest of the changes needed to use the alternative page?

看看SDK中的示例代码。具体位置:

Take a look at the sample code in the SDK. Specifically here:

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));
    }
}

这篇关于用`WinRTXamlToolkit.Controls.AlternativePage`替换`Page`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆