{"id":45589,"date":"2019-10-22T09:48:02","date_gmt":"2019-10-22T16:48:02","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/xamarin\/?p=45589"},"modified":"2019-10-22T09:48:02","modified_gmt":"2019-10-22T16:48:02","slug":"xamarin-forms-4-3-introducing-collectionview","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/xamarin-forms-4-3-introducing-collectionview\/","title":{"rendered":"Xamarin.Forms 4.3 is live! Introducing CollectionView"},"content":{"rendered":"<p>Today we\u2019re incredibly pleased to announce the stable release of Xamarin.Forms 4.3.0. This release marks the removal of the experimental flag from CollectionView as it moves into stable status. Along with this, comes a number of enhancements and contributions from the community. Including SourceLink support, the ability to display HTML on Labels, and more.<\/p>\n<h3>Using CollectionView<\/h3>\n<p>With Xamarin.Forms 4.3.0, you can now use CollectionView in your apps without the need for the Experimental flag enabled. If you haven\u2019t used CollectionView before, go check out the <a href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/xamarin-forms\/user-interface\/collectionview\/\">docs<\/a> to learn more and download the samples. CollectionView is built to be fast, uses modern, native controls, and removes the concept of ViewCells. Simply set your View inside a DataTemplate:\n&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">    &lt;StackLayout Margin=\"20\"&gt;\r\n        &lt;CollectionView ItemsSource=\"{Binding Monkeys}\"&gt;\r\n            &lt;CollectionView.ItemTemplate&gt;\r\n                &lt;DataTemplate&gt;\r\n                    &lt;Grid Padding=\"10\"&gt;\r\n                        &lt;Grid.RowDefinitions&gt;\r\n                            &lt;RowDefinition Height=\"Auto\" \/&gt;\r\n                            &lt;RowDefinition Height=\"Auto\" \/&gt;\r\n                        &lt;\/Grid.RowDefinitions&gt;\r\n                        &lt;Grid.ColumnDefinitions&gt;\r\n                            &lt;ColumnDefinition Width=\"Auto\" \/&gt;\r\n                            &lt;ColumnDefinition Width=\"Auto\" \/&gt;\r\n                        &lt;\/Grid.ColumnDefinitions&gt;\r\n                        &lt;Image Grid.RowSpan=\"2\" \r\n                               Source=\"{Binding ImageUrl}\" \r\n                               Aspect=\"AspectFill\"\r\n                               HeightRequest=\"60\" \r\n                               WidthRequest=\"60\" \/&gt;\r\n                        &lt;Label Grid.Column=\"1\" \r\n                               Text=\"{Binding Name}\" \r\n                               FontAttributes=\"Bold\" \/&gt;\r\n                        &lt;Label Grid.Row=\"1\"\r\n                               Grid.Column=\"1\" \r\n                               Text=\"{Binding Location}\"\r\n                               FontAttributes=\"Italic\" \r\n                               VerticalOptions=\"End\" \/&gt;\r\n                    &lt;\/Grid&gt;\r\n                &lt;\/DataTemplate&gt;\r\n            &lt;\/CollectionView.ItemTemplate&gt;\r\n        &lt;\/CollectionView&gt;\r\n    &lt;\/StackLayout&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-45635\" src=\"http:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/10\/WeatherColors-using-CollectionView.gif\" alt=\"Xamarin.Forms 4.3 - WeatherColors using CollectionView\" width=\"1161\" height=\"603\" \/><\/p>\n<p>For more information on getting started with CollectionView, visit the\u00a0<a style=\"background-color: #f7f7f9;\" href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/xamarin-forms\/user-interface\/collectionview\/\">docs<\/a>.<\/p>\n<h4>RefreshView<\/h4>\n<p>Xamarin.Forms 4.3 also introduces RefreshView. The need for pull-to-refresh functionality was a top piece of feedback during the <a href=\"https:\/\/devblogs.microsoft.com\/xamarin\/xamarin-forms-4-0-collectionview-challenge\/\">CollectionView Challenge<\/a>. RefreshView provides pull-to-refresh functionality to any child which supports scrollable content:<\/p>\n<pre class=\"lang:default decode:true\">&lt;RefreshView IsRefreshing=\"{Binding IsRefreshing}\"\r\n             Command=\"{Binding RefreshCommand}\"&gt;\r\n    &lt;CollectionView ItemsSource=\"{Binding Animals}\"&gt;\r\n        ...\r\n    &lt;\/CollectionView&gt;\r\n&lt;\/RefreshView&gt;<\/pre>\n<p>Visit the <a href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/xamarin-forms\/user-interface\/refreshview\/\">docs<\/a> to learn more about RefreshView.<\/p>\n<h3>Additional Features<\/h3>\n<p>Xamarin.Forms 4.3.0 also brings additional enhancements. As mentioned earlier, two of those particularly notable additions include SourceLink support within Xamarin.Forms. As well as the ability to display HTML on Labels.<\/p>\n<h5>SourceLink Support (<a href=\"https:\/\/github.com\/xamarin\/Xamarin.Forms\/pull\/6886\">#6886<\/a>)<\/h5>\n<p>With SourceLink support added to Xamarin.Forms, easily step into the source code for a first-class debugging experience. Learn more through the <a href=\"https:\/\/github.com\/dotnet\/sourcelink\">SourceLink GitHub repo<\/a>.<\/p>\n<h5>Displaying HTML on a Label (<a href=\"https:\/\/github.com\/xamarin\/Xamarin.Forms\/pull\/4527\">#4527<\/a>)<\/h5>\n<p>By setting the <span class=\"lang:default decode:true crayon-inline\">TextType<\/span>\u00a0 property on the Label to <span class=\"lang:default decode:true crayon-inline \">Html<\/span>, your string values can be parsed as HTML. Then display appropriately on a Label:<\/p>\n<pre class=\"lang:c# decode:true\">var labelUsingHTML = new Label\r\n{\r\n    Text = \"&lt;h1&gt;Hello from Xamarin.Forms!&lt;\/h1&gt;&lt;\/br&gt;This &lt;i&gt;Label&lt;\/i&gt;'s text is being displayed with &lt;b&gt;HTML&lt;\/b&gt;!\",\r\n    TextType = TextType.Html,\r\n    VerticalOptions = LayoutOptions.CenterAndExpand,\r\n    HorizontalTextAlignment = TextAlignment.Center\r\n};<\/pre>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-45623\" src=\"http:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/10\/HTML.png\" alt=\"Xamarin.Forms 4.3 - A Label displaying HTML\" width=\"316\" height=\"613\" srcset=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/10\/HTML.png 486w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/10\/HTML-155x300.png 155w\" sizes=\"(max-width: 316px) 100vw, 316px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Additional enhancements include:<\/p>\n<ul>\n<li>Character spacing (kerning) for Labels and Buttons (<a href=\"https:\/\/github.com\/xamarin\/Xamarin.Forms\/pull\/5167\">#5167<\/a>)<\/li>\n<li>Padding on Labels (<a href=\"https:\/\/github.com\/xamarin\/Xamarin.Forms\/pull\/6299\">#6299<\/a>)<\/li>\n<li>Scrolled event for ListView (<a href=\"https:\/\/github.com\/xamarin\/Xamarin.Forms\/pull\/7157\">#7157<\/a>)<\/li>\n<\/ul>\n<h3>Xamarin.Forms 4.3.0 Preview Features<\/h3>\n<p>In addition to all of the above, Xamarin.Forms 4.3.0 also includes previews of CarouselView and Shell support in UWP.<\/p>\n<h4>Using CarouselView<\/h4>\n<p>In our recent <a href=\"https:\/\/devblogs.microsoft.com\/xamarin\/carouselview-challenge-wrap-up\/\">CarouselView Challenge Wrap-up<\/a> we showed off some fantastic submissions from the community and dug further into our findings. To summarize, you clearly indicated that your top desire for the CarouselView is the ability to display position indicators. Additionally, you also expressed the desire for better refresh functionality and more control around transitions.<\/p>\n<p>Thanks to your feedback, we have placed CarouselView under an Experimental flag for this 4.3.0 release. You can enable it by setting the following flag before calling:<\/p>\n<ul>\n<li><span class=\"lang:default decode:true crayon-inline \">Init()<\/span>\u00a0 in the <span class=\"lang:default decode:true crayon-inline\">MainActivity.cs<\/span>\u00a0 of your Android project.<\/li>\n<li><span class=\"lang:default decode:true crayon-inline \">AppDelegate.cs<\/span>\u00a0 of your iOS project.<\/li>\n<li><span class=\"lang:default decode:true crayon-inline \">App.xaml.cs<\/span>\u00a0 of your UWP project:<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">Xamarin.Forms.Forms.SetFlags(\"CarouselView_Experimental\");<\/pre>\n<p>Our current plan is to continue to refine CarouselView. Then implement these desired features before removing the experimental flag.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-45538\" src=\"http:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/10\/carouselviewchallenge-5.gif\" alt=\"A submission by Javier Su\u00e1rez Ruiz\" width=\"336\" height=\"534\" \/><\/p>\n<h4>Preview Shell Support in UWP<\/h4>\n<p>Shell support is now available for UWP as a preview under the Experimental flags. To enable it in your existing UWP apps, add the following line of code before calling Init() in the <span class=\"lang:default decode:true crayon-inline \">App.xaml.cs<\/span>\u00a0 file of your UWP project:<\/p>\n<pre class=\"lang:default decode:true\">Xamarin.Forms.Forms.SetFlags(\"Shell_UWP_Experimental\");<\/pre>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-45622\" src=\"http:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/10\/gastropods.gif\" alt=\"The Gastropods sample running on UWP\" width=\"640\" height=\"468\" \/><\/p>\n<p>If you need to add a UWP project to your solution, follow the <a href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/xamarin-forms\/platform\/windows\/installation\/\">documentation<\/a>. We would like to thank <a href=\"https:\/\/github.com\/xamarin\/Xamarin.Forms\/pull\/6015\">Morton Nielsen<\/a> for the effort put in on this implementation.<\/p>\n<h3>Upgrade to 4.3 Today<\/h3>\n<p>For full details about Xamarin.Forms 4.3.0, check the <a href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/xamarin-forms\/release-notes\/4.3\/4.3.0\" target=\"_blank\" rel=\"noopener noreferrer\">release notes<\/a>.<\/p>\n<p>You can update your existing projects via the NuGet Package Manager. As always, feedback is very welcome. Should you encounter any problems or have suggestions, please open an issue on\u00a0<a href=\"https:\/\/github.com\/xamarin\/Xamarin.Forms\/issues\/new\/choose\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Announcing the stable release of Xamarin.Forms 4.3.0! Marking the removal of the experimental flag from CollectionView as it moves into stable status. Along with this, comes a number of enhancements and contributions from the community including SourceLink support, the ability to display HTML on Labels, and more!<\/p>\n","protected":false},"author":738,"featured_media":45635,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5216,367],"tags":[6909,751,6690,16],"class_list":["post-45589","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcements","category-xamarin-forms","tag-4-3","tag-collectionview","tag-xamarin-challenge","tag-xamarin-forms"],"acf":[],"blog_post_summary":"<p>Announcing the stable release of Xamarin.Forms 4.3.0! Marking the removal of the experimental flag from CollectionView as it moves into stable status. Along with this, comes a number of enhancements and contributions from the community including SourceLink support, the ability to display HTML on Labels, and more!<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/45589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/738"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=45589"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/45589\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/45635"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=45589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=45589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=45589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}