{"id":2154,"date":"2021-07-10T15:56:56","date_gmt":"2021-07-10T15:56:56","guid":{"rendered":"https:\/\/sezeromer.com\/?p=2154"},"modified":"2023-03-04T13:48:25","modified_gmt":"2023-03-04T10:48:25","slug":"xamarin-forms-indicator-view","status":"publish","type":"post","link":"https:\/\/sezeromer.com\/en\/xamarin-forms-indicator-view\/","title":{"rendered":"Xamarin Forms Indicator View"},"content":{"rendered":"<p>Hello friends, in this article, we will talk about how to use Indicator View with <strong>Xamarin Forms<\/strong>. First of all, if you ask what IndicatorView is, you can access detailed information from <a href=\"https:\/\/docs.microsoft.com\/tr-tr\/xamarin\/xamarin-forms\/user-interface\/indicatorview\">here<\/a>. You can find previous <strong>Xamarin<\/strong> articles <a href=\"https:\/\/sezeromer.com\/xamarin\/\">here<\/a>.<\/p>\n<p>It is generally used when making gallery pages or in structures that can be scrolled to the side. In this way, the user can see how many items are sideways. We used to use different Nuget Packages for this in the past, but as of <strong>Xamarin 5.0 versions<\/strong>, we can do it using IndicatorView. If you are using one of the <strong>Xamarin 4.x.x versions<\/strong>, you should add a Flag. Because it was more experimental in these versions and its use was not recommended.<\/p>\n<p>In our example, we will put a <strong>CarouselView<\/strong> to occupy one-third of the screen. We will use an IndicatorView to show how many items are in the CarouselView. I will display animal names in CarouselView. You can also use your own different designs. The design is as follows.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-2159\" src=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/Simulator-Screen-Shot-iPhone-12-2021-07-10-at-18.45.37-473x1024.png\" alt=\"\" width=\"473\" height=\"1024\" \/><\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">&lt;?xml version=\"1.0\" encoding=\"utf-8\" ?&gt;\r\n&lt;ContentPage xmlns=\"http:\/\/xamarin.com\/schemas\/2014\/forms\"\r\n             xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2009\/xaml\"\r\n             x:Class=\"indicator_view.MainPage\"&gt;\r\n\r\n    &lt;Grid HorizontalOptions=\"FillAndExpand\"\r\n          VerticalOptions=\"FillAndExpand\"&gt;\r\n        &lt;Grid.RowDefinitions&gt;\r\n            &lt;RowDefinition Height=\"*\"\/&gt;\r\n            &lt;RowDefinition Height=\"2*\"\/&gt;\r\n        &lt;\/Grid.RowDefinitions&gt;\r\n        &lt;Grid HorizontalOptions=\"FillAndExpand\"\r\n              VerticalOptions=\"FillAndExpand\"\r\n              Grid.Row=\"0\"&gt;\r\n            &lt;CarouselView HorizontalOptions=\"FillAndExpand\"\r\n                          VerticalOptions=\"FillAndExpand\"\r\n                          HorizontalScrollBarVisibility=\"Never\"\r\n                          VerticalScrollBarVisibility=\"Never\"\r\n                          x:Name=\"collectionView\"\r\n                          Loop=\"False\"\r\n                          IndicatorView=\"{x:Reference indicatorView}\"&gt;\r\n                &lt;CarouselView.ItemTemplate&gt;\r\n                    &lt;DataTemplate&gt;\r\n                        &lt;Grid HorizontalOptions=\"FillAndExpand\"\r\n                              VerticalOptions=\"FillAndExpand\"&gt;\r\n                            &lt;Label HorizontalOptions=\"FillAndExpand\"\r\n                                   VerticalOptions=\"FillAndExpand\"\r\n                                   HorizontalTextAlignment=\"Center\"\r\n                                   VerticalTextAlignment=\"Center\"\r\n                                   Text=\"{Binding Name}\"\/&gt;\r\n                        &lt;\/Grid&gt;\r\n                    &lt;\/DataTemplate&gt;\r\n                &lt;\/CarouselView.ItemTemplate&gt;\r\n            &lt;\/CarouselView&gt;\r\n            &lt;IndicatorView HorizontalOptions=\"Center\"\r\n                           VerticalOptions=\"End\"\r\n                           IndicatorColor=\"Red\"\r\n                           SelectedIndicatorColor=\"Blue\"\r\n                           x:Name=\"indicatorView\"\r\n                           HideSingle=\"False\"\r\n                           IndicatorsShape=\"Circle\"\r\n                           IndicatorSize=\"10\"\/&gt;\r\n        &lt;\/Grid&gt;\r\n        &lt;Grid HorizontalOptions=\"FillAndExpand\"\r\n              VerticalOptions=\"FillAndExpand\"\r\n              Grid.Row=\"1\"\r\n              BackgroundColor=\"Yellow\"\/&gt;\r\n    &lt;\/Grid&gt;\r\n\r\n&lt;\/ContentPage&gt;<\/pre>\n<\/div>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">using System;\r\nusing System.Collections.Generic;\r\nusing System.Collections.ObjectModel;\r\nusing System.ComponentModel;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing Xamarin.Forms;\r\n\r\nnamespace indicator_view\r\n{\r\n    public partial class MainPage : ContentPage\r\n    {\r\n        public MainPage()\r\n        {\r\n            InitializeComponent();\r\n            collectionView.ItemsSource = GetAnimals();\r\n        }\r\n\r\n        ObservableCollection&lt;Animal&gt; GetAnimals()\r\n        {\r\n            return new ObservableCollection&lt;Animal&gt;()\r\n            {\r\n                new Animal\r\n                {\r\n                    Name = \"Dog\"\r\n                },\r\n                new Animal\r\n                {\r\n                    Name = \"Cat\"\r\n                },\r\n                new Animal\r\n                {\r\n                    Name = \"Horse\"\r\n                },\r\n                new Animal\r\n                {\r\n                    Name = \"Monkey\"\r\n                },\r\n                new Animal\r\n                {\r\n                    Name = \"Bird\"\r\n                }\r\n            };\r\n        }\r\n    }\r\n\r\n    public class Animal\r\n    {\r\n        public string Name { get; set; }\r\n    }\r\n}<\/pre>\n<\/div>\n<p>If you want the CarouselView to return directly after the last element in your project, you should set the Loop property to True. If you want the IndicatorView not to appear when there is only one item, it will be enough to set the HideSingle property as True. You can use many different features like this. Below is an image of how it works.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2158\" src=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/17.gif\" alt=\"\" width=\"364\" height=\"788\" \/><\/p>\n<p>If you have questions, you can reach us by sending an e-mail or comment. Good work.<\/p>","protected":false},"excerpt":{"rendered":"<p>Hello friends, in this article, we will talk about how to use Indicator View with Xamarin Forms. First of all, if you ask what IndicatorView is, you can access detailed information from here. You can find previous Xamarin articles here. It is generally used when making gallery pages or in structures that can be scrolled [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2159,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[804,289,288,803,802,3],"tags":[583,851,403,758,312,849,8,7,440,850,566,22,848],"class_list":["post-2154","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-maui-android","category-android","category-ios","category-maui-ios","category-maui","category-xamarin-ile-yapilmis-projeler","tag-carousel","tag-carousel-view","tag-forms","tag-gallery","tag-indicator","tag-indicator-view","tag-omer","tag-omer-sezer","tag-sezer","tag-vieew","tag-view","tag-xamarin","tag-xxamarin-forms"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/2154"}],"collection":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/comments?post=2154"}],"version-history":[{"count":6,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/2154\/revisions"}],"predecessor-version":[{"id":2676,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/2154\/revisions\/2676"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media\/2159"}],"wp:attachment":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media?parent=2154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/categories?post=2154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/tags?post=2154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}