question

JassimAlRahma-9056 avatar image
0 Votes"
JassimAlRahma-9056 asked YonglunLiu-MSFT commented

Load ContentPage into CarouselPage

Hi,

In below example I have multiple ContentPages inside my CarouselPage but this will make the file too long and difficult to maintain,

Can I create a separate ContentPage file for each of them and then load it into my CarouselPage?

How can I do that please?


  <?xml version="1.0" encoding="utf-8" ?>
  <CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
      xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
      ios:Page.UseSafeArea="True" 
      CurrentPageChanged="CarouselPage_CurrentPageChanged"
      x:Class="Kalko.MainPage">
      <NavigationPage.TitleView>
          <StackLayout>
          <Label Text="Home Page" VerticalOptions="Center" />
          <Image HorizontalOptions="End" VerticalOptions="Center">
          <Image.Source>
              <FontImageSource FontFamily="FontSolid" Size="30" Glyph="{StaticResource IconFavorite}" />
          </Image.Source>
          </Image>
          </StackLayout>
      </NavigationPage.TitleView>
      <ContentPage x:Name="ContentPageHomePage">
      </ContentPage>
      <ContentPage x:Name="ContentPagePag2">
      </ContentPage>
      <ContentPage x:Name="ContentPagePag3">
      </ContentPage>
      <ContentPage x:Name="ContentPagePag4">
      </ContentPage>
  </CarouselPage>



dotnet-xamarin
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Removed the dotnet-maui tag since your code snippet is Xamarin and not MAUI. Please use only relevant tags for your question.

0 Votes 0 ·

I have not heard from you for a couple of days. Please let me know if there is anything that I can help here.

0 Votes 0 ·

1 Answer

YonglunLiu-MSFT avatar image
0 Votes"
YonglunLiu-MSFT answered

Hello,

You can refer to CarouselPage Class to find the solution in Remarks.

If you want to load ContentPages into your CarouselPage, you could use the Children property to set your pages.

Best Regards,

Alec Liu.




If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.