Xamarin formsCarousel View with Text, Image in center of the Screen With Dots indicator in Below












1














How to do carousel view in Xamarin Forms. I have a splash page after the splash page I need to show the four instruction page with dot indicator in the bottom of the page. each page has a different image, text. I tried but not able to get it.
Here is My Code:



   public Carousel(ObservableCollection<CarouselContent> pages)
{
HorizontalOptions = LayoutOptions.FillAndExpand;
HorizontalOptions = LayoutOptions.FillAndExpand;
carousel = new CarouselView();
carousel.HorizontalOptions = LayoutOptions.FillAndExpand;
carousel.VerticalOptions = LayoutOptions.FillAndExpand;

var template = new DataTemplate(() => {
var page1 = new AbsoluteLayout();
page1.BackgroundColor = Color.FromHex("050C29");
page1.HorizontalOptions = LayoutOptions.FillAndExpand;
page1.VerticalOptions = LayoutOptions.FillAndExpand;
page1.SetBinding(AbsoluteLayout.BackgroundColorProperty, "BackgroundColor");
var image = new Image();
image.SetBinding(Image.SourceProperty, "Image");
image.HorizontalOptions = LayoutOptions.FillAndExpand;
image.VerticalOptions = LayoutOptions.Center;
var lab = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) + 10,
FontAttributes = FontAttributes.Bold
};
lab.TextColor = Color.White;
lab.HorizontalOptions = LayoutOptions.Center;
lab.VerticalOptions = LayoutOptions.Center;
lab.FontFamily = "BrandonGrotesque-Bold.otf";
lab.FontSize = 30;
lab.SetBinding(Label.TextProperty, "Header");
var lab2 = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
};
lab2.TextColor = Color.White;
lab2.HorizontalOptions = LayoutOptions.Center;
lab2.VerticalOptions = LayoutOptions.Center;
lab.FontFamily = "BrandonGrotesque-Bold.otf";
lab.FontSize = 24;
lab2.SetBinding(Label.TextProperty, "Content1");
page1.Children.Add(image);
page1.Children.Add(lab);
page1.Children.Add(lab2);
StackLayout stackLayout = new StackLayout();
stackLayout.Children.Add(page1);

AbsoluteLayout.SetLayoutBounds(image, new Rectangle(2, 0, 1, 0));
AbsoluteLayout.SetLayoutFlags(image, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(lab, new Rectangle(0, 0.3, 1, 0.2));
AbsoluteLayout.SetLayoutFlags(lab, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(lab2, new Rectangle(0, 0.4, 1, 0.2));
AbsoluteLayout.SetLayoutFlags(lab2, AbsoluteLayoutFlags.All);

return page1;
});

carousel.ItemsSource = pages;
carousel.ItemTemplate = template;
carousel.PositionSelected += pageChanged;
Children.Add(carousel);

}









share|improve this question
























  • Can you post the code you tried?
    – Dinesh Phalwadiya
    Dec 28 '18 at 9:58










  • @DineshPhalwadiya i have posted my code what i have tried.
    – Sarvan
    Dec 31 '18 at 4:14
















1














How to do carousel view in Xamarin Forms. I have a splash page after the splash page I need to show the four instruction page with dot indicator in the bottom of the page. each page has a different image, text. I tried but not able to get it.
Here is My Code:



   public Carousel(ObservableCollection<CarouselContent> pages)
{
HorizontalOptions = LayoutOptions.FillAndExpand;
HorizontalOptions = LayoutOptions.FillAndExpand;
carousel = new CarouselView();
carousel.HorizontalOptions = LayoutOptions.FillAndExpand;
carousel.VerticalOptions = LayoutOptions.FillAndExpand;

var template = new DataTemplate(() => {
var page1 = new AbsoluteLayout();
page1.BackgroundColor = Color.FromHex("050C29");
page1.HorizontalOptions = LayoutOptions.FillAndExpand;
page1.VerticalOptions = LayoutOptions.FillAndExpand;
page1.SetBinding(AbsoluteLayout.BackgroundColorProperty, "BackgroundColor");
var image = new Image();
image.SetBinding(Image.SourceProperty, "Image");
image.HorizontalOptions = LayoutOptions.FillAndExpand;
image.VerticalOptions = LayoutOptions.Center;
var lab = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) + 10,
FontAttributes = FontAttributes.Bold
};
lab.TextColor = Color.White;
lab.HorizontalOptions = LayoutOptions.Center;
lab.VerticalOptions = LayoutOptions.Center;
lab.FontFamily = "BrandonGrotesque-Bold.otf";
lab.FontSize = 30;
lab.SetBinding(Label.TextProperty, "Header");
var lab2 = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
};
lab2.TextColor = Color.White;
lab2.HorizontalOptions = LayoutOptions.Center;
lab2.VerticalOptions = LayoutOptions.Center;
lab.FontFamily = "BrandonGrotesque-Bold.otf";
lab.FontSize = 24;
lab2.SetBinding(Label.TextProperty, "Content1");
page1.Children.Add(image);
page1.Children.Add(lab);
page1.Children.Add(lab2);
StackLayout stackLayout = new StackLayout();
stackLayout.Children.Add(page1);

AbsoluteLayout.SetLayoutBounds(image, new Rectangle(2, 0, 1, 0));
AbsoluteLayout.SetLayoutFlags(image, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(lab, new Rectangle(0, 0.3, 1, 0.2));
AbsoluteLayout.SetLayoutFlags(lab, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(lab2, new Rectangle(0, 0.4, 1, 0.2));
AbsoluteLayout.SetLayoutFlags(lab2, AbsoluteLayoutFlags.All);

return page1;
});

carousel.ItemsSource = pages;
carousel.ItemTemplate = template;
carousel.PositionSelected += pageChanged;
Children.Add(carousel);

}









share|improve this question
























  • Can you post the code you tried?
    – Dinesh Phalwadiya
    Dec 28 '18 at 9:58










  • @DineshPhalwadiya i have posted my code what i have tried.
    – Sarvan
    Dec 31 '18 at 4:14














1












1








1







How to do carousel view in Xamarin Forms. I have a splash page after the splash page I need to show the four instruction page with dot indicator in the bottom of the page. each page has a different image, text. I tried but not able to get it.
Here is My Code:



   public Carousel(ObservableCollection<CarouselContent> pages)
{
HorizontalOptions = LayoutOptions.FillAndExpand;
HorizontalOptions = LayoutOptions.FillAndExpand;
carousel = new CarouselView();
carousel.HorizontalOptions = LayoutOptions.FillAndExpand;
carousel.VerticalOptions = LayoutOptions.FillAndExpand;

var template = new DataTemplate(() => {
var page1 = new AbsoluteLayout();
page1.BackgroundColor = Color.FromHex("050C29");
page1.HorizontalOptions = LayoutOptions.FillAndExpand;
page1.VerticalOptions = LayoutOptions.FillAndExpand;
page1.SetBinding(AbsoluteLayout.BackgroundColorProperty, "BackgroundColor");
var image = new Image();
image.SetBinding(Image.SourceProperty, "Image");
image.HorizontalOptions = LayoutOptions.FillAndExpand;
image.VerticalOptions = LayoutOptions.Center;
var lab = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) + 10,
FontAttributes = FontAttributes.Bold
};
lab.TextColor = Color.White;
lab.HorizontalOptions = LayoutOptions.Center;
lab.VerticalOptions = LayoutOptions.Center;
lab.FontFamily = "BrandonGrotesque-Bold.otf";
lab.FontSize = 30;
lab.SetBinding(Label.TextProperty, "Header");
var lab2 = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
};
lab2.TextColor = Color.White;
lab2.HorizontalOptions = LayoutOptions.Center;
lab2.VerticalOptions = LayoutOptions.Center;
lab.FontFamily = "BrandonGrotesque-Bold.otf";
lab.FontSize = 24;
lab2.SetBinding(Label.TextProperty, "Content1");
page1.Children.Add(image);
page1.Children.Add(lab);
page1.Children.Add(lab2);
StackLayout stackLayout = new StackLayout();
stackLayout.Children.Add(page1);

AbsoluteLayout.SetLayoutBounds(image, new Rectangle(2, 0, 1, 0));
AbsoluteLayout.SetLayoutFlags(image, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(lab, new Rectangle(0, 0.3, 1, 0.2));
AbsoluteLayout.SetLayoutFlags(lab, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(lab2, new Rectangle(0, 0.4, 1, 0.2));
AbsoluteLayout.SetLayoutFlags(lab2, AbsoluteLayoutFlags.All);

return page1;
});

carousel.ItemsSource = pages;
carousel.ItemTemplate = template;
carousel.PositionSelected += pageChanged;
Children.Add(carousel);

}









share|improve this question















How to do carousel view in Xamarin Forms. I have a splash page after the splash page I need to show the four instruction page with dot indicator in the bottom of the page. each page has a different image, text. I tried but not able to get it.
Here is My Code:



   public Carousel(ObservableCollection<CarouselContent> pages)
{
HorizontalOptions = LayoutOptions.FillAndExpand;
HorizontalOptions = LayoutOptions.FillAndExpand;
carousel = new CarouselView();
carousel.HorizontalOptions = LayoutOptions.FillAndExpand;
carousel.VerticalOptions = LayoutOptions.FillAndExpand;

var template = new DataTemplate(() => {
var page1 = new AbsoluteLayout();
page1.BackgroundColor = Color.FromHex("050C29");
page1.HorizontalOptions = LayoutOptions.FillAndExpand;
page1.VerticalOptions = LayoutOptions.FillAndExpand;
page1.SetBinding(AbsoluteLayout.BackgroundColorProperty, "BackgroundColor");
var image = new Image();
image.SetBinding(Image.SourceProperty, "Image");
image.HorizontalOptions = LayoutOptions.FillAndExpand;
image.VerticalOptions = LayoutOptions.Center;
var lab = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) + 10,
FontAttributes = FontAttributes.Bold
};
lab.TextColor = Color.White;
lab.HorizontalOptions = LayoutOptions.Center;
lab.VerticalOptions = LayoutOptions.Center;
lab.FontFamily = "BrandonGrotesque-Bold.otf";
lab.FontSize = 30;
lab.SetBinding(Label.TextProperty, "Header");
var lab2 = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
};
lab2.TextColor = Color.White;
lab2.HorizontalOptions = LayoutOptions.Center;
lab2.VerticalOptions = LayoutOptions.Center;
lab.FontFamily = "BrandonGrotesque-Bold.otf";
lab.FontSize = 24;
lab2.SetBinding(Label.TextProperty, "Content1");
page1.Children.Add(image);
page1.Children.Add(lab);
page1.Children.Add(lab2);
StackLayout stackLayout = new StackLayout();
stackLayout.Children.Add(page1);

AbsoluteLayout.SetLayoutBounds(image, new Rectangle(2, 0, 1, 0));
AbsoluteLayout.SetLayoutFlags(image, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(lab, new Rectangle(0, 0.3, 1, 0.2));
AbsoluteLayout.SetLayoutFlags(lab, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(lab2, new Rectangle(0, 0.4, 1, 0.2));
AbsoluteLayout.SetLayoutFlags(lab2, AbsoluteLayoutFlags.All);

return page1;
});

carousel.ItemsSource = pages;
carousel.ItemTemplate = template;
carousel.PositionSelected += pageChanged;
Children.Add(carousel);

}






xamarin.forms carousel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 28 '18 at 18:23







Sarvan

















asked Dec 28 '18 at 7:42









SarvanSarvan

114




114












  • Can you post the code you tried?
    – Dinesh Phalwadiya
    Dec 28 '18 at 9:58










  • @DineshPhalwadiya i have posted my code what i have tried.
    – Sarvan
    Dec 31 '18 at 4:14


















  • Can you post the code you tried?
    – Dinesh Phalwadiya
    Dec 28 '18 at 9:58










  • @DineshPhalwadiya i have posted my code what i have tried.
    – Sarvan
    Dec 31 '18 at 4:14
















Can you post the code you tried?
– Dinesh Phalwadiya
Dec 28 '18 at 9:58




Can you post the code you tried?
– Dinesh Phalwadiya
Dec 28 '18 at 9:58












@DineshPhalwadiya i have posted my code what i have tried.
– Sarvan
Dec 31 '18 at 4:14




@DineshPhalwadiya i have posted my code what i have tried.
– Sarvan
Dec 31 '18 at 4:14












1 Answer
1






active

oldest

votes


















0














Hi I did by adding three static images into CarouselPage. Each image have its own highlighted dot and button in the bottom of the static image.
Add CarouselPage plugin from Nouget and do the following code;



<CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyProject.Views.Login"
xmlns:pages="clr-namespace:MyProject.Views"
Title="CarouselPage">

<ContentPage>
<StackLayout>
<Image HorizontalOptions="Center" VerticalOptions="Center" Source="bg_splash.png" Aspect="AspectFill"></Image>
</StackLayout>
</ContentPage>
<ContentPage>
<StackLayout>
<Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_1.png" Aspect="AspectFill"></Image>
</StackLayout>
</ContentPage>
<ContentPage>
<StackLayout>
<Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_2.png" Aspect="AspectFill"></Image>
</StackLayout>
</ContentPage>
<ContentPage>
<StackLayout>
<Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_3.png" Aspect="AspectFill"></Image>
</StackLayout>
</ContentPage>
<pages:LoginPage/>




In carousel page which image is visible in view do highlighted dot for that image like this ..*..






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53955214%2fxamarin-formscarousel-view-with-text-image-in-center-of-the-screen-with-dots-in%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Hi I did by adding three static images into CarouselPage. Each image have its own highlighted dot and button in the bottom of the static image.
    Add CarouselPage plugin from Nouget and do the following code;



    <CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyProject.Views.Login"
    xmlns:pages="clr-namespace:MyProject.Views"
    Title="CarouselPage">

    <ContentPage>
    <StackLayout>
    <Image HorizontalOptions="Center" VerticalOptions="Center" Source="bg_splash.png" Aspect="AspectFill"></Image>
    </StackLayout>
    </ContentPage>
    <ContentPage>
    <StackLayout>
    <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_1.png" Aspect="AspectFill"></Image>
    </StackLayout>
    </ContentPage>
    <ContentPage>
    <StackLayout>
    <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_2.png" Aspect="AspectFill"></Image>
    </StackLayout>
    </ContentPage>
    <ContentPage>
    <StackLayout>
    <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_3.png" Aspect="AspectFill"></Image>
    </StackLayout>
    </ContentPage>
    <pages:LoginPage/>




    In carousel page which image is visible in view do highlighted dot for that image like this ..*..






    share|improve this answer




























      0














      Hi I did by adding three static images into CarouselPage. Each image have its own highlighted dot and button in the bottom of the static image.
      Add CarouselPage plugin from Nouget and do the following code;



      <CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
      x:Class="MyProject.Views.Login"
      xmlns:pages="clr-namespace:MyProject.Views"
      Title="CarouselPage">

      <ContentPage>
      <StackLayout>
      <Image HorizontalOptions="Center" VerticalOptions="Center" Source="bg_splash.png" Aspect="AspectFill"></Image>
      </StackLayout>
      </ContentPage>
      <ContentPage>
      <StackLayout>
      <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_1.png" Aspect="AspectFill"></Image>
      </StackLayout>
      </ContentPage>
      <ContentPage>
      <StackLayout>
      <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_2.png" Aspect="AspectFill"></Image>
      </StackLayout>
      </ContentPage>
      <ContentPage>
      <StackLayout>
      <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_3.png" Aspect="AspectFill"></Image>
      </StackLayout>
      </ContentPage>
      <pages:LoginPage/>




      In carousel page which image is visible in view do highlighted dot for that image like this ..*..






      share|improve this answer


























        0












        0








        0






        Hi I did by adding three static images into CarouselPage. Each image have its own highlighted dot and button in the bottom of the static image.
        Add CarouselPage plugin from Nouget and do the following code;



        <CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        x:Class="MyProject.Views.Login"
        xmlns:pages="clr-namespace:MyProject.Views"
        Title="CarouselPage">

        <ContentPage>
        <StackLayout>
        <Image HorizontalOptions="Center" VerticalOptions="Center" Source="bg_splash.png" Aspect="AspectFill"></Image>
        </StackLayout>
        </ContentPage>
        <ContentPage>
        <StackLayout>
        <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_1.png" Aspect="AspectFill"></Image>
        </StackLayout>
        </ContentPage>
        <ContentPage>
        <StackLayout>
        <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_2.png" Aspect="AspectFill"></Image>
        </StackLayout>
        </ContentPage>
        <ContentPage>
        <StackLayout>
        <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_3.png" Aspect="AspectFill"></Image>
        </StackLayout>
        </ContentPage>
        <pages:LoginPage/>




        In carousel page which image is visible in view do highlighted dot for that image like this ..*..






        share|improve this answer














        Hi I did by adding three static images into CarouselPage. Each image have its own highlighted dot and button in the bottom of the static image.
        Add CarouselPage plugin from Nouget and do the following code;



        <CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        x:Class="MyProject.Views.Login"
        xmlns:pages="clr-namespace:MyProject.Views"
        Title="CarouselPage">

        <ContentPage>
        <StackLayout>
        <Image HorizontalOptions="Center" VerticalOptions="Center" Source="bg_splash.png" Aspect="AspectFill"></Image>
        </StackLayout>
        </ContentPage>
        <ContentPage>
        <StackLayout>
        <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_1.png" Aspect="AspectFill"></Image>
        </StackLayout>
        </ContentPage>
        <ContentPage>
        <StackLayout>
        <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_2.png" Aspect="AspectFill"></Image>
        </StackLayout>
        </ContentPage>
        <ContentPage>
        <StackLayout>
        <Image HorizontalOptions="Center" VerticalOptions="Center" Source="img_about_3.png" Aspect="AspectFill"></Image>
        </StackLayout>
        </ContentPage>
        <pages:LoginPage/>




        In carousel page which image is visible in view do highlighted dot for that image like this ..*..







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 28 '18 at 9:02

























        answered Dec 28 '18 at 8:48









        PrasanthPrasanth

        424




        424






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53955214%2fxamarin-formscarousel-view-with-text-image-in-center-of-the-screen-with-dots-in%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas