2

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>

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>

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.

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?

Charles
  • 50,943
  • 13
  • 104
  • 142
Kyle
  • 17,317
  • 32
  • 140
  • 246
  • In the exceptions dialog (Ctrl-alt-E if using C# scheme), choose to break on any exception. Post the callstack you are seeing there. – Shahar Prish Apr 21 '13 at 13:44
  • @ShaharPrish I have it set to break on all exception. Nothing gets thrown until the `throw new Exception("Failed to create initial page");` Thats why I'm having a hard time trying to figure out what is going on. – Kyle Apr 21 '13 at 13:50
  • Please note that Windows Runtime ("WinRT") is *not* the same thing as Windows RT. The former is a development architecture, while the latter is Windows 8 on tablets. – Charles Apr 21 '13 at 14:37
  • @Zenox: You are right. I should have read the code more closely. – Shahar Prish Apr 21 '13 at 14:41
  • Note that you don't need AlternativeFrame or AlternativePage to use the Treeview. These are there for page transition and preloading support. – Filip Skakun Apr 21 '13 at 19:58

1 Answers1

2

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

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));
    }
}
Shahar Prish
  • 4,838
  • 3
  • 26
  • 47
  • Sure did not! I completely missed those when I was looking over the changes I need. once I put the AppShell in place its working. Thanks! – Kyle Apr 21 '13 at 14:56