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