質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
UWP

UWPは、Universal Windows Platformの略。様々なデバイス向けに提供されているアプリケーションを共通のフレームワーク上で動作可能にする仕組みで、Windows10で導入されました。

XAML

XAML(Extensible Application Markup Language)はWPF、Silverlight、Windows PhoneそしてWindows Store appsでユーザーインターフェースを定義するために使われるXML言語です。

継承

継承(インヘリタンス)はオブジェクト指向プログラミングに存在するシステムです。継承はオブジェクトが各自定義する必要をなくし、継承元のオブジェクトで定義されている内容を引き継ぎます。

Xamarin

Xamarin(ザマリン)は、iPhoneなどのiOSやAndroidで動作し、C# 言語を用いてアプリを開発できるクロスプラットフォーム開発環境です。Xamarin Studioと C# 言語を用いて、 iOS と Android の両方の開発を行うことができます。

Q&A

0回答

532閲覧

UWPでCarouselPageを使用する方法

hirotamasami

総合スコア5

UWP

UWPは、Universal Windows Platformの略。様々なデバイス向けに提供されているアプリケーションを共通のフレームワーク上で動作可能にする仕組みで、Windows10で導入されました。

XAML

XAML(Extensible Application Markup Language)はWPF、Silverlight、Windows PhoneそしてWindows Store appsでユーザーインターフェースを定義するために使われるXML言語です。

継承

継承(インヘリタンス)はオブジェクト指向プログラミングに存在するシステムです。継承はオブジェクトが各自定義する必要をなくし、継承元のオブジェクトで定義されている内容を引き継ぎます。

Xamarin

Xamarin(ザマリン)は、iPhoneなどのiOSやAndroidで動作し、C# 言語を用いてアプリを開発できるクロスプラットフォーム開発環境です。Xamarin Studioと C# 言語を用いて、 iOS と Android の両方の開発を行うことができます。

0グッド

0クリップ

投稿2021/05/11 05:08

前提・実現したいこと

以下のサイト
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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問