前提・実現したいこと
以下のサイト
https://www.atmarkit.co.jp/ait/articles/1611/24/news039.html
を参考にUWPでCarouselPageを使用するために
以下のようなクラスを作成しました。
C#
public sealed partial class MainPage : CarouselPage { public MainPage() { this.InitializeComponent(); } } <CarouselPage x:Class="TestUWPSlidePage.MainPage" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:TestUWPSlidePage" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <local:Page2 /> <local:Page3 /> </CarouselPage>
C#
public sealed partial class Page3 : ContentPage { public Page3() { //this.InitializeComponent(); } } <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="TestUWPSlidePage.Page3" xmlns:local="using:TestUWPSlidePage" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <!-- <ContentPage.Padding> <OnPlatform x:TypeArguments="Thickness" iOS="0,40,0,0" Android="0,40,0,0" /> </ContentPage.Padding> --> <StackLayout> <Label Text="Page-3" FontSize="Large" HorizontalOptions="Center" /> <BoxView Color="Red" WidthRequest="200" HeightRequest="200" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" /> </StackLayout> </ContentPage>
C#
public sealed partial class Page2 : ContentPage { public Page2() { //this.InitializeComponent(); } } <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="TestUWPSlidePage.Page2" xmlns:local="using:TestUWPSlidePage" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <!-- <ContentPage.Padding> <OnPlatform x:TypeArguments="Thickness" iOS="0,40,0,0" Android="0,40,0,0" /> </ContentPage.Padding> --> <StackLayout> <Label Text="Page-2" FontSize="Large" HorizontalOptions="Center" /> <BoxView Color="Green" WidthRequest="200" HeightRequest="200" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" /> </StackLayout> </ContentPage>
この状態で
普通のPageクラスの時と同様に
Appクラスで
rootFrame.Navigate(typeof(MainPage), e.Arguments);//rootFrameはFrameクラスのインスタンス
で画面を表示しようとしたところ、
System.NullReferenceException
が発生して画面遷移できませんでした。
CarouselPageはPageクラスを継承しているので、
rootFrame.Navigate
を使用すれば、
画面遷移可能と思っていたのですが、
できないのでしょうか?
また
rootFrame.Navigate
で遷移できない場合、
UWPでCarouselPageを使用するには
どのようにすればよろしいでしょうか?
情報不足ありましたら
ご指摘ください。
宜しくお願い致します。
補足情報(FW/ツールのバージョンなど)
・OS バージョン Windows10
まだ回答がついていません
会員登録して回答してみよう