{"id":571,"date":"2018-01-14T19:46:11","date_gmt":"2018-01-14T19:46:11","guid":{"rendered":"http:\/\/sezeromer.com\/?p=571"},"modified":"2023-02-26T12:37:15","modified_gmt":"2023-02-26T09:37:15","slug":"xamarin-list-view-kullanimi","status":"publish","type":"post","link":"https:\/\/sezeromer.com\/en\/xamarin-list-view-kullanimi\/","title":{"rendered":"Xamarin Using ListView"},"content":{"rendered":"<p>You may be receiving data from internet or you may want to keep tour data in a sequential order. To do this, you need to export your data to list and print it on the screen using a\u00a0<strong>ListView\u00a0<\/strong>in\u00a0<strong>Xamarin.<\/strong> I will talk about this in my article today.<\/p>\n<p>First we open a project. With this project we are opening, rebuild and wait for packages to settle. Then we need to set a standart for a data sorting. We must vreate a model for this. In this article iwould like to show you a guide application example. We create a model called G\u0131ide. In this model we will store information such as name, surname, number, mail and home address.<\/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;}\">public class Rehber\r\n    {\r\n        public string Ad { get; set; }\r\n        public string Soyad { get; set; }\r\n        public string Numara { get; set; }\r\n        public string Mail { get; set; }\r\n        public string Adres { get; set; }\r\n\r\n\r\n    }<\/pre>\n<\/div>\n<p>Then we will design the page that will display the guide. First we assign a title. Later in the <strong>StackLayout<\/strong> by putting a <strong>ListView<\/strong> we will store our data regularly around here. Here, using the <strong>Grids<\/strong>, name surnames and numbers will be displayed regularly.<\/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;StackLayout&gt;\r\n            &lt;!-- Ba\u015fl\u0131k k\u0131sm\u0131--&gt;\r\n            &lt;StackLayout Padding=\"20\"&gt;\r\n                &lt;Label HorizontalTextAlignment=\"Center\"\r\n                       Text=\"REHBER\"\r\n                       FontAttributes=\"Bold\"\r\n                       TextColor=\"Black\"\/&gt;\r\n            &lt;\/StackLayout&gt;\r\n            &lt;!-- Rehberin g\u00f6r\u00fcnt\u00fclece\u011fi k\u0131sm\u0131 tasarl\u0131yrouz--&gt;\r\n            &lt;StackLayout&gt;\r\n                &lt;ListView x:Name=\"listRehber\" ItemsSource=\"{Binding .}\"&gt;\r\n                    &lt;ListView.ItemTemplate&gt;\r\n                        &lt;DataTemplate&gt;\r\n                            &lt;ViewCell&gt;\r\n                                &lt;ViewCell.View&gt;\r\n                                    &lt;Grid&gt;\r\n                                        &lt;Grid.ColumnDefinitions&gt;\r\n                                            &lt;ColumnDefinition Width=\"*\"\/&gt;\r\n                                            &lt;ColumnDefinition Width=\"*\"\/&gt;\r\n                                        &lt;\/Grid.ColumnDefinitions&gt;\r\n                                        &lt;Grid Grid.Column=\"0\"&gt;\r\n                                            &lt;Grid.ColumnDefinitions&gt;\r\n                                                &lt;ColumnDefinition Width=\"*\"\/&gt;\r\n                                                &lt;ColumnDefinition Width=\"*\"\/&gt;\r\n                                            &lt;\/Grid.ColumnDefinitions&gt;\r\n                                            &lt;Label Text=\"{Binding Ad}\"\r\n                                                   TextColor=\"Black\"\r\n                                                   Grid.Column=\"0\"\/&gt;\r\n                                            &lt;Label Text=\"{Binding Soyad}\"\r\n                                                   TextColor=\"Black\"\r\n                                                   Grid.Column=\"1\"\/&gt;\r\n                                        &lt;\/Grid&gt;\r\n                                        &lt;StackLayout Grid.Column=\"1\"&gt;\r\n                                            &lt;Label Text=\"{Binding Numara}\"\r\n                                                   TextColor=\"Black\"\r\n                                                   \/&gt;\r\n                                        &lt;\/StackLayout&gt;\r\n                                    &lt;\/Grid&gt;\r\n                                &lt;\/ViewCell.View&gt;\r\n                            &lt;\/ViewCell&gt;\r\n                        &lt;\/DataTemplate&gt;\r\n                    &lt;\/ListView.ItemTemplate&gt;\r\n                &lt;\/ListView&gt;\r\n            &lt;\/StackLayout&gt;\r\n        &lt;\/StackLayout&gt;<\/pre>\n<\/div>\n<p>When we come to the .cs part of this page, first we need to add a few numbers to the pavilion so let&#8217;s show it to the list. I am creating a function for this. Here I add 3 peoples to the list of contacts so that the list does not appear empty.<\/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;}\">public void ListeDoldur(List&lt;Rehber&gt; list)\r\n        {\r\n            list.Add(new Rehber\r\n            {\r\n                Ad = \"\u00d6mer\",\r\n                Soyad = \"Sezer\",\r\n                Numara = \"21423423525\",\r\n                Mail = \"oomersezer@gmail.com\",\r\n                Adres = \"asdadasdasd\"\r\n            });\r\n            list.Add(new Rehber\r\n            {\r\n                Ad = \"Mehmet\",\r\n                Soyad = \"\u015e\u00fckr\u00fc\",\r\n                Numara = \"2141241241\",\r\n\r\n            });\r\n            list.Add(new Rehber\r\n            {\r\n                Ad = \"Ahmet\",\r\n                Soyad = \"Veli\",\r\n                Numara = \"34235235\"\r\n            });\r\n        }<\/pre>\n<\/div>\n<p>Then I put the list I added directly into the <strong>ListView<\/strong> that I created in the design section.<\/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;}\">List&lt;Rehber&gt; liste = new List&lt;Rehber&gt;();\r\n\tpublic AnaSayfa ()\r\n\t{\r\n\t    InitializeComponent ();\r\n            ListeDoldur(liste);\r\n            listRehber.BindingContext = liste;\r\n\t}<\/pre>\n<\/div>\n<p>The screen output is as follows.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-648\" src=\"http:\/\/sezeromer.com\/wp-content\/uploads\/2018\/01\/lv-kullanimi.png\" alt=\"\" width=\"501\" height=\"886\" srcset=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2018\/01\/lv-kullanimi.png 501w, https:\/\/sezeromer.com\/wp-content\/uploads\/2018\/01\/lv-kullanimi-170x300.png 170w\" sizes=\"(max-width: 501px) 100vw, 501px\" \/><\/p>\n<p>You can reach the project <a href=\"https:\/\/github.com\/omersezer\/ListView\">here<\/a>. If you have any questions about <strong>ListView<\/strong>, you can reach us by comment or mail.<\/p>","protected":false},"excerpt":{"rendered":"<p>You may be receiving data from internet or you may want to keep tour data in a sequential order. To do this, you need to export your data to list and print it on the screen using a\u00a0ListView\u00a0in\u00a0Xamarin. I will talk about this in my article today. First we open a project. With this project [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":650,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[289,288,3],"tags":[114,132,245,150,249,248,7,246,247,22,119],"class_list":["post-571","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-ios","category-xamarin-ile-yapilmis-projeler","tag-android","tag-grid","tag-kullanimi","tag-list-view","tag-liste","tag-listview-kullanimi","tag-omer-sezer","tag-rehber","tag-stacklayout","tag-xamarin","tag-xamarin-forms"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/571"}],"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=571"}],"version-history":[{"count":5,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/571\/revisions"}],"predecessor-version":[{"id":2566,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/571\/revisions\/2566"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media\/650"}],"wp:attachment":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media?parent=571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/categories?post=571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/tags?post=571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}