{"id":33454,"date":"2017-09-28T12:45:37","date_gmt":"2017-09-28T19:45:37","guid":{"rendered":"https:\/\/blog.xamarin.com\/?p=33454"},"modified":"2017-09-28T12:45:37","modified_gmt":"2017-09-28T19:45:37","slug":"xamarin-forms-stable-comes-to-net-standard-2-0","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/xamarin-forms-stable-comes-to-net-standard-2-0\/","title":{"rendered":"Xamarin.Forms Stable Comes to .NET Standard 2.0"},"content":{"rendered":"<p>\t\t\t\tToday, we are thrilled to share our latest stable release of Xamarin.Forms, version 2.4.0. This is our fastest, most stable release ever and we think you\u2019re going to love it!<\/p>\n<h3>Xamarin.Forms 2.4.0 Highlights<\/h3>\n<p>You\u2019ll recognize many of these highlights as shared in our <a href=\"https:\/\/forums.xamarin.com\/85747\/xamarin-forms-feature-roadmap\/p1\">public roadmap<\/a>, in addition to more than 150 bug fixes.<\/p>\n<ul>\n<li>.NET Standard 2.0 Support<\/li>\n<li>New Feature Flags API<\/li>\n<li>Android Fast Renderers: Button, Image, Label<\/li>\n<li>macOS Preview<\/li>\n<\/ul>\n<p>A huge thanks to the more than 20 amazing community members that contributed to making this a fantastic release.<\/p>\n<h4>.NET Standard 2.0 Support<\/h4>\n<p>As support begins to take off for .NET Standard 2.0, we have made sure Xamarin.Forms works seamlessly with both the standard and existing PCL profiles. To get started with .NET Standard and Xamarin.Forms, you can create a new .NET Standard Library project.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/netstandard_library.png\" alt=\"\" width=\"1888\" height=\"1309\" class=\"aligncenter size-full wp-image-33456\" \/><\/p>\n<p>Next, add the Xamarin.Forms 2.4.0 NuGet dependency so you\u2019re ready to start adding your Xamarin.Forms project files. Before you go too far, though, be sure to read the <a href=\"https:\/\/developer.xamarin.com\/releases\/xamarin-forms\/xamarin-forms-2.4\/2.4.0-stable\/\" rel=\"noopener\" target=\"_blank\">important release notes<\/a>.<\/p>\n<h4>New Feature Flags API<\/h4>\n<p>We are introducing a new API to enable or disable features by setting a feature flag just before initializing Xamarin.Forms. This will enable you to benefit from features or behaviors that may be of high value to you without introducing changes that you may not want. As of 2.4.0, the Fast Renderers for Android are the first feature to take advantage of this.<\/p>\n<p>To enable Fast Renderers on Android:<\/p>\n<pre><code>public partial class Activity1 : FormsAppCompatActivity\n{\n    protected override void OnCreate(Bundle bundle)\n    {\n                ...\n                Forms.SetFlags(\"FastRenderers_Experimental\");\n                Forms.Init(this, bundle);\n                ...\n    }\n}\n<\/code><\/pre>\n<h4>Android Fast Renderers<\/h4>\n<p>Fast Renderers are a refactoring of the renderer architecture to optimize for performance and memory consumption. In the original renderer design, a wrapper class is used for convenience to expose the renderer API. This has the side effect of an additional UI element wrapping each and every native UI element.<\/p>\n<p>You can see an example UI hierarchy that is generated without Fast Renderers in the diagram below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/Slide52-1.jpg\" alt=\"\" width=\"1306\" height=\"734\" class=\"aligncenter size-full wp-image-33461\" \/><\/p>\n<p>Now take a look at the UI hierarchy after we remove the need for that wrapping element.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/Slide53-1.jpg\" alt=\"\" width=\"1306\" height=\"734\" class=\"aligncenter size-full wp-image-33462\" \/><\/p>\n<p>I&#8217;ll save you some counting; we were able to reduce the number of UI elements from 19 to 13! The net result is a faster, more memory-responsible UI.<\/p>\n<p>We&#8217;re shipping Fast Renderers on Android for Button, Image, and Label controls in 2.4.0, and we&#8217;ll continue to work on shipping more of these for Android as well as other platforms going forward.<\/p>\n<p>Due to the changes necessary to make this happen, and the likelihood of the API changing while we work on additional controls, these classes are currently sealed and opt-in via the aforementioned Feature Flags API. We&#8217;ll expose the classes and consider enabling them by default once we&#8217;ve finalized the API.<\/p>\n<h3>macOS Preview<\/h3>\n<p>As I blogged previously, <a href=\"https:\/\/blog.xamarin.com\/preview-bringing-macos-to-xamarin-forms\/\">Xamarin.Forms macOS is available<\/a> in preview! We&#8217;ve made several bug fixes in 2.4.0 to the work that was introduced during the pre-release cycle. Now you can easily extend your Xamarin.Forms applications to macOS.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-33471\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/Screenshot-2017-09-28-10.39.38.png\" alt=\"\" width=\"1544\" height=\"1400\" \/><\/p>\n<p>If you author a 3rd party library or component for Xamarin.Forms, now is the time to make sure it\u2019s compatible with macOS projects.<\/p>\n<p>Let us know <a href=\"https:\/\/forums.xamarin.com\/93585\/preview-xamarin-forms-for-macos\" target=\"_blank\" rel=\"noopener noreferrer\">in the forum discussion<\/a> what you think about this preview, show us what you&#8217;re working on, and help us identify what we need to do to improve macOS for a stable release.<\/p>\n<h3>Update Today<\/h3>\n<p>This release is available today via NuGet. Be sure to review the <a>full release notes<\/a> and, as usual, when upgrading an existing solution, update all projects in your solution that reference Xamarin.Forms.<\/p>\n<p><a href=\"https:\/\/forums.xamarin.com\/104053\/xamarin-forms-2-4-0-282\" target=\"_blank\">Discuss this post on the Xamarin Forums<\/a>.\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, we are thrilled to share our latest stable release of Xamarin.Forms, version 2.4.0. This is our fastest, most stable release ever and we think you\u2019re going to love it! Xamarin.Forms 2.4.0 Highlights You\u2019ll recognize many of these highlights as shared in our public roadmap, in addition to more than 150 bug fixes. .NET Standard [&hellip;]<\/p>\n","protected":false},"author":553,"featured_media":39167,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[16],"class_list":["post-33454","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-xamarin-forms"],"acf":[],"blog_post_summary":"<p>Today, we are thrilled to share our latest stable release of Xamarin.Forms, version 2.4.0. This is our fastest, most stable release ever and we think you\u2019re going to love it! Xamarin.Forms 2.4.0 Highlights You\u2019ll recognize many of these highlights as shared in our public roadmap, in addition to more than 150 bug fixes. .NET Standard [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/33454","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\/553"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=33454"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/33454\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/39167"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=33454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=33454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=33454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}