Windows 8 从SwapChainBackgroundPanel导航到最后一帧

Windows 8 从SwapChainBackgroundPanel导航到最后一帧,windows-8,winrt-xaml,windows-store-apps,directx-11,Windows 8,Winrt Xaml,Windows Store Apps,Directx 11,我正在使用C++/XAML和DirectX interop-SwapChainBackgroundPanel编写一个Windows应用商店应用程序 该应用程序基于模板“拆分页面”。从每个列表视图项中,可以使用下面的代码启动DirectX页面 Window::Current->Content = ref new MyD3Components::DirectXPage(); Window::Current->Activate(); 这是良好的工作和DirectX页面打开和发挥非常好 我

我正在使用C++/XAML和DirectX interop-SwapChainBackgroundPanel编写一个Windows应用商店应用程序

该应用程序基于模板“拆分页面”。从每个列表视图项中,可以使用下面的代码启动DirectX页面

Window::Current->Content = ref new MyD3Components::DirectXPage();
Window::Current->Activate();
这是良好的工作和DirectX页面打开和发挥非常好

我希望在应用程序栏中有一个按钮,帮助用户返回并显示“拆分页面”,以允许选择另一个DirectX页面。这一点我还没有做到

在我尝试过的几件事情中,以下是我认为最符合逻辑的一件。当用户想要返回到最后一页时,它会给出一个“Platform::DisconnectedException”

Windows::UI::Xaml::Controls::Frame^ rootFrame = SDL::App::GetRootFrame();

Window::Current->Content = rootFrame;
Window::Current->Activate();

请查看您是否有建议或更好的解决方案。

以下是您问题的示例:

我正在创建:2页。。。 您将在第1页上有(转到第2页)链接…如果您单击该链接,第二页的顶部将显示“第2页”。请注意,页面标题左侧有一个后退按钮。单击按钮返回到第一页

1.)找到名为pageTitle的TextBlock元素,并将Text属性更改为第1页。XAML应该如下所示:

<TextBlock x:Name="pageTitle" Grid.Column="1" Text="Page 1" 
       Style="{StaticResource PageHeaderTextStyle}"/>
<TextBlock x:Name="pageTitle" Grid.Column="1" Text="Page 2" 
       Style="{StaticResource PageHeaderTextStyle}"/>
6.)现在我们已经准备好了新页面,我们需要让BasicPage1成为应用程序启动时出现的第一件事。打开app.xaml.cs并将OnLaunched方法更改为call Frame。使用BasicPage1而不是BlankPage进行导航。整个OnLaunched方法应如下所示:

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
// Create a Frame to act navigation context and navigate to the first page
var rootFrame = new Frame();
rootFrame.Navigate(typeof(BasicPage1));

// Place the frame in the current window and ensure that it is active
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
现在,您已准备好测试该应用程序。启动应用程序,然后单击显示“单击以转到第2页”的链接。第二页应在顶部显示“第2页”。请注意,页面标题左侧有一个后退按钮。单击按钮返回到第一页。
就这样!希望它能对你有所帮助。

经过一番尝试和错误,我现在可以回答我自己的问题了。似乎我所需要做的就是从CompositionTarget中删除渲染调用

它被添加如下

m_eventToken = CompositionTarget::Rendering::add(ref new Windows::Foundation::EventHandler<Object^>(this, &DirectXPage::OnRendering));    

我猜这有助于DirectX在目标不存在时不输出到渲染管道和抱怨(disconnectedexception)。

谢谢您的回答,但它没有解决我的问题。在我的例子中,涉及DirectX interop,SwapChainBackgroundPanel,我认为这是问题的根源。
private void HyperlinkButton_Click_1(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(BasicPage2));
}
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
// Create a Frame to act navigation context and navigate to the first page
var rootFrame = new Frame();
rootFrame.Navigate(typeof(BasicPage1));

// Place the frame in the current window and ensure that it is active
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
m_eventToken = CompositionTarget::Rendering::add(ref new Windows::Foundation::EventHandler<Object^>(this, &DirectXPage::OnRendering));    
CompositionTarget::Rendering::remove(m_eventToken);