LoginSignup
1
2

More than 5 years have passed since last update.

UWP+Prismでナビゲーションが効かない(初歩的な)問題

Last updated at Posted at 2016-09-16

引っかかったところ

 UWPとPrismを使ってアプリを作ろうとしたけど、最低限のコードを動かそうとしても、MainPage.xmlのところまで飛ばずにナビゲーションが失敗してしまう(例外が投げられる)現象に遭遇した。

コード

App.xaml.cs
    protected override Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args)
    {
        //ここで失敗する
        NavigationService.Navigate("Main", null);

        return Task.FromResult<object>(null);
    }

遭遇する現象

App.g.i.cs
//ここでブレークする
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();

例外の内容

{"The page name Main does not have an associated type in namespace [プロジェクト名].Views\r\nParameter name: pageToken"} System.ArgumentException

解決方法

ナビゲートするView(ここではMainPage.xml)はViews名前空間下にないといけないらしい。

MainPage.xaml
<Page
    x:Class="SosowaReader.Views.MainPage"
    <!--略-->
/>

追記

書いてあった。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2