{"id":33882,"date":"2017-10-24T12:52:54","date_gmt":"2017-10-24T19:52:54","guid":{"rendered":"https:\/\/blog.xamarin.com\/?p=33882"},"modified":"2017-10-24T12:52:54","modified_gmt":"2017-10-24T19:52:54","slug":"3-big-things-explore-xamarin-forms-2-5-0-pre-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/3-big-things-explore-xamarin-forms-2-5-0-pre-release\/","title":{"rendered":"3 Big Things To Explore in the Xamarin.Forms 2.5.0 Pre-Release"},"content":{"rendered":"<p>\t\t\t\tOver the past year we\u2019ve been working on a couple of &#8220;big things&#8221; that enable you to create more performant applications on more platforms. With our latest stable release, <a href=\"https:\/\/developer.xamarin.com\/releases\/xamarin-forms\/xamarin-forms-2.4\/2.4.0-sr2\/\" target=\"_blank\" rel=\"noopener noreferrer\">version 2.4.0<\/a>, we introduced performance optimized renderers on Android,\u00a0nicknamed <em>Fast Renderers<\/em>. While faster platform renderers are a clear win, you really start to see the big gains using them in combination with a new feature, debuting in 2.5.0, called <em>Layout Compression<\/em>. Not to be eclipsed by those performance focused boosts, we&#8217;re also releasing <em>Forms Embedding<\/em> in this preview. We&#8217;re excited to\u00a0take these improvements off the pages of our <a href=\"https:\/\/forums.xamarin.com\/85747\/xamarin-forms-feature-roadmap\/p1\" target=\"_blank\" rel=\"noopener noreferrer\">public roadmap<\/a>\u00a0and put them into your hands. Read on for details on how you can start benefiting from these fantastic improvements, and much more.<\/p>\n<h3>Big Thing 1: Layout Compression<\/h3>\n<p>When optimizing\u00a0a layout for performance, whether for the purpose of smoother animation or\u00a0speed of rendering, you quickly learn the value of having a flat view hierarchy. Take this page\u00a0for example:<\/p>\n<pre class=\"height-set:true lang:xhtml decode:true\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;ContentPage \n    xmlns=\"http:\/\/xamarin.com\/schemas\/2014\/forms\" \n    xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2009\/xaml\" \n    xmlns:local=\"clr-namespace:ProfileLayout\" \n    x:Class=\"ProfileLayout.ProfileLayoutPage\"\n    xmlns:views=\"using:ProfileLayout.Views\"\n    xmlns:controls=\"clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions\"\n    xmlns:converters=\"using:ProfileLayout.Converters;\"\n    Title=\"Profile\"\n    BackgroundColor=\"#F3F3F3\"&gt;\n    &lt;ContentPage.Resources&gt;\n        &lt;ResourceDictionary&gt;\n            &lt;converters:InvertedBoolConverter x:Key=\"InvertedBoolConverter\"\/&gt;\n    \n            &lt;!-- Global Colors --&gt;\n            &lt;Color\n                x:Key=\"primaryColor\"&gt;#303030&lt;\/Color&gt;\n            &lt;Color\n                x:Key=\"secondaryColor\"&gt;#C9AE98&lt;\/Color&gt;\n            &lt;Color\n                x:Key=\"validationColor\"&gt;#FF3F56&lt;\/Color&gt;\n            &lt;Color\n                x:Key=\"callToActionColor\"&gt;#4E8B4F&lt;\/Color&gt;\n            &lt;Color\n                x:Key=\"accentColor\"&gt;White&lt;\/Color&gt;\n            &lt;Color\n                x:Key=\"darkAccentColor\"&gt;#7c6a5c&lt;\/Color&gt;\n            &lt;!-- Global Sizes --&gt;\n            &lt;x:Double\n                x:Key=\"mediumTextSize\"&gt;20&lt;\/x:Double&gt;&lt;x:Double\n                x:Key=\"smallTextSize\"&gt;14&lt;\/x:Double&gt;&lt;x:Double\n                x:Key=\"standardPadding\"&gt;10&lt;\/x:Double&gt;\n\n            &lt;!-- Global Element Styles --&gt;\n            &lt;Style\n                TargetType=\"Entry\"&gt;\n                &lt;Setter\n                    Property=\"HeightRequest\"\n                    Value=\"44\" \/&gt;\n                &lt;Setter\n                    Property=\"TextColor\"\n                    Value=\"{StaticResource darkAccentColor}\" \/&gt;\n            &lt;\/Style&gt;\n\n            &lt;Style\n                TargetType=\"NavigationPage\"&gt;&lt;Setter\n                    Property=\"BarBackgroundColor\"\n                    Value=\"{StaticResource primaryColor}\" \/&gt;&lt;\/Style&gt;&lt;Style\n                TargetType=\"Frame\"&gt;&lt;Setter\n                    Property=\"BackgroundColor\"\n                    Value=\"{StaticResource accentColor}\" \/&gt;&lt;Setter\n                    Property=\"Padding\"\n                    Value=\"{StaticResource standardPadding}\" \/&gt;&lt;Setter\n                    Property=\"HasShadow\"\n                    Value=\"False\" \/&gt;&lt;Setter\n                    Property=\"OutlineColor\"\n                    Value=\"{StaticResource secondaryColor}\" \/&gt;&lt;\/Style&gt;&lt;!-- Label Styles --&gt;&lt;Style\n                x:Key=\"switchLabel\"\n                TargetType=\"Label\"&gt;&lt;Setter\n                    Property=\"TextColor\"\n                    Value=\"#999999\" \/&gt;&lt;Setter\n                    Property=\"VerticalOptions\"\n                    Value=\"Center\" \/&gt;&lt;Setter\n                    Property=\"HorizontalOptions\"\n                    Value=\"FillAndExpand\" \/&gt;&lt;\/Style&gt;&lt;!-- Button Styles --&gt;&lt;Style\n                x:Key=\"callToActionButton\"\n                TargetType=\"Button\"&gt;&lt;Setter\n                    Property=\"BackgroundColor\"\n                    Value=\"{StaticResource callToActionColor}\" \/&gt;&lt;Setter\n                    Property=\"TextColor\"\n                    Value=\"{StaticResource accentColor}\" \/&gt;&lt;Setter\n                    Property=\"FontSize\"\n                    Value=\"{StaticResource mediumTextSize}\" \/&gt;&lt;\/Style&gt;\n            &lt;Style\n                x:Key=\"primaryButton\"\n                TargetType=\"Button\"&gt;\n                &lt;Setter\n                    Property=\"BackgroundColor\"\n                    Value=\"{StaticResource primaryColor}\" \/&gt;\n                &lt;Setter\n                    Property=\"TextColor\"\n                    Value=\"{StaticResource accentColor}\" \/&gt;\n                &lt;Setter\n                    Property=\"FontSize\"\n                    Value=\"{StaticResource smallTextSize}\" \/&gt;&lt;\/Style&gt;\n\n            &lt;Style\n                x:Key=\"nakedButton\"\n                TargetType=\"Button\"&gt;\n                &lt;Setter\n                    Property=\"BackgroundColor\"\n                    Value=\"Transparent\" \/&gt;\n                &lt;Setter\n                    Property=\"TextColor\"\n                    Value=\"{StaticResource accentColor}\" \/&gt;\n                &lt;Setter \n                    Property=\"BorderColor\"\n                    Value=\"Transparent\"\/&gt;\n                &lt;Setter \n                    Property=\"BorderWidth\"\n                    Value=\"0\"\/&gt;\n                &lt;Setter\n                    Property=\"FontSize\"\n                    Value=\"{StaticResource mediumTextSize}\" \/&gt;&lt;\/Style&gt;\n\n            &lt;Style\n                x:Key=\"whiteClearButton\"\n                TargetType=\"Button\"&gt;\n                &lt;Setter\n                    Property=\"BackgroundColor\"\n                    Value=\"Transparent\" \/&gt;\n                &lt;Setter\n                    Property=\"BorderColor\"\n                    Value=\"{StaticResource accentColor}\" \/&gt;\n                &lt;Setter\n                    Property=\"BorderWidth\"\n                    Value=\"1\" \/&gt;\n                &lt;Setter\n                    Property=\"TextColor\"\n                    Value=\"{StaticResource accentColor}\" \/&gt;\n                &lt;Setter\n                    Property=\"FontSize\"\n                    Value=\"{StaticResource smallTextSize}\" \/&gt;\n            &lt;\/Style&gt;\n\n            &lt;Style\n                x:Key=\"secondaryButton\"\n                TargetType=\"Button\"&gt;&lt;Setter\n                    Property=\"BackgroundColor\"\n                    Value=\"{StaticResource secondaryColor}\" \/&gt;&lt;Setter\n                    Property=\"TextColor\"\n                    Value=\"{StaticResource accentColor}\" \/&gt;&lt;Setter\n                    Property=\"FontSize\"\n                    Value=\"{StaticResource smallTextSize}\" \/&gt;&lt;Setter\n                    Property=\"FontAttributes\"\n                    Value=\"Bold\" \/&gt;&lt;\/Style&gt;&lt;Style\n                x:Key=\"footerButton\"\n                TargetType=\"Button\"&gt;&lt;Setter\n                    Property=\"BackgroundColor\"\n                    Value=\"{StaticResource secondaryColor}\" \/&gt;&lt;Setter\n                    Property=\"TextColor\"\n                    Value=\"{StaticResource accentColor}\" \/&gt;&lt;Setter\n                    Property=\"FontSize\"\n                    Value=\"{StaticResource smallTextSize}\" \/&gt;&lt;Setter\n                    Property=\"FontAttributes\"\n                    Value=\"Bold\" \/&gt;&lt;Setter\n                    Property=\"HorizontalOptions\"\n                    Value=\"FillAndExpand\" \/&gt;&lt;\/Style&gt;\n        &lt;\/ResourceDictionary&gt;\n    &lt;\/ContentPage.Resources&gt;\n    &lt;ContentPage.Padding&gt;\n        &lt;OnPlatform x:TypeArguments=\"Thickness\" iOS=\"0,0,0,0\" Android=\"0,0,0,0\" \/&gt;\n    &lt;\/ContentPage.Padding&gt;\n\n    &lt;ContentPage.Content&gt;\n        \n        &lt;StackLayout\n            Spacing=\"0\"\n            VerticalOptions=\"FillAndExpand\"\n            HorizontalOptions=\"FillAndExpand\"&gt;\n            &lt;AbsoluteLayout\n                BackgroundColor=\"#909090\"\n                HorizontalOptions=\"FillAndExpand\"\n                HeightRequest=\"60\"&gt;\n                &lt;AbsoluteLayout.Padding&gt;\n                    &lt;OnPlatform x:TypeArguments=\"Thickness\" iOS=\"0,20,0,0\" Android=\"0,0,0,0\" \/&gt;\n                &lt;\/AbsoluteLayout.Padding&gt;\n                &lt;Button\n                    Margin=\"10,10\"\n                    FontSize=\"12\"\n                    Text=\"Cancel\"\n                    BackgroundColor=\"Transparent\"\n                    Command=\"{Binding CancelCommand}\"\n                    Style=\"{StaticResource nakedButton}\"\/&gt;\n                &lt;Image \n                    AbsoluteLayout.LayoutBounds=\"0.5, 0.5, 0.36, 0.7\"\n                    AbsoluteLayout.LayoutFlags=\"All\"\n                    BackgroundColor=\"Transparent\" \n                    HeightRequest=\"36\"\n                    Source=\"microsoft_gray.png\" \/&gt;\n                &lt;Button\n                    IsVisible=\"{Binding IsLoggedIn}\"\n                    Margin=\"10,10\"\n                    BackgroundColor=\"Transparent\"\n                    AbsoluteLayout.LayoutBounds=\"1, 0, AutoSize, AutoSize\"\n                    AbsoluteLayout.LayoutFlags=\"PositionProportional\"\n                    FontSize=\"12\"\n                    Text=\"Logout\"\n                    Command=\"{Binding LogoutCommand}\"\n                    Style=\"{StaticResource nakedButton}\"\/&gt;\n            &lt;\/AbsoluteLayout&gt;\n\n            &lt;Label\n                HorizontalOptions=\"FillAndExpand\"\n                BackgroundColor=\"#D1D1D1\"\n                HeightRequest=\"22\"\n                TextColor=\"#000000\"\n                FontSize=\"14\" \n                HorizontalTextAlignment=\"Center\"\n                Text=\"{Binding Title}\"\/&gt;\n\n            &lt;ScrollView HorizontalOptions=\"FillAndExpand\" VerticalOptions=\"FillAndExpand\"&gt;\n\n            &lt;StackLayout\n            Spacing=\"0\"\n            VerticalOptions=\"FillAndExpand\"\n            HorizontalOptions=\"FillAndExpand\"&gt;\n\n                &lt;Button\n                    Margin=\"0,10,0,0\"\n                    IsVisible=\"{Binding CanEdit}\"\n                    Text=\"    EDIT    \"\n                    Style=\"{StaticResource primaryButton}\"\n                    BackgroundColor=\"#9B9B9B\"\n                    HeightRequest=\"35\"\n                    HorizontalOptions=\"Center\"\n                    Command=\"{Binding ToggleEditModeCommand}\"\n                    \/&gt;\n\n                &lt;Button\n                    Margin=\"0,10,0,0\"\n                    IsVisible=\"{Binding IsEditing}\"\n                    Text=\"    EDITING    \"\n                    BackgroundColor=\"#9B9B9B\"\n                    Style=\"{StaticResource primaryButton}\"\n                    HeightRequest=\"35\"\n                    HorizontalOptions=\"Center\"\n                    Command=\"{Binding ToggleEditModeCommand}\"\n                \/&gt;\n\n            &lt;StackLayout\n                Margin=\"20\"\n                Spacing=\"20\"\n                HorizontalOptions=\"FillAndExpand\"\n                Orientation=\"Horizontal\"&gt;\n\n                &lt;StackLayout \n                    Spacing=\"10\"\n                    Orientation=\"Vertical\"&gt;\n\n                        &lt;controls:CircleImage \n                            x:Name=\"ProfilePic\"\n                            Source=\"david.jpg\" \n                            BorderThickness=\"3\"\n                            BorderColor=\"#9B9B9B\"\n                            Aspect=\"AspectFill\"&gt;\n                            &lt;controls:CircleImage.WidthRequest&gt;\n                                &lt;OnPlatform x:TypeArguments=\"x:Double\"\n                                  iOS=\"104\"\n                                  Android=\"104\"\n                                  WinPhone=\"104\"\/&gt;\n                            &lt;\/controls:CircleImage.WidthRequest&gt;\n                            &lt;controls:CircleImage.HeightRequest&gt;\n                                &lt;OnPlatform x:TypeArguments=\"x:Double\"\n                                  iOS=\"104\"\n                                  Android=\"104\"\n                                  WinPhone=\"104\"\/&gt;\n                            &lt;\/controls:CircleImage.HeightRequest&gt;\n                        &lt;\/controls:CircleImage&gt;\n\n                        &lt;Button\n                            IsVisible=\"{Binding CanSave}\"\n                            Text=\"Change Photo\"\n                            Style=\"{StaticResource nakedButton}\"\n                            FontSize=\"12\"\n                            BorderColor=\"Transparent\"\n                            BorderWidth=\"0\"\n                            BackgroundColor=\"Transparent\"\n                            TextColor=\"#303030\"\n                        &gt;\n                        &lt;\/Button&gt;\n                    &lt;\/StackLayout&gt;\n\n                &lt;StackLayout \n                    Spacing=\"10\"\n                    HorizontalOptions=\"FillAndExpand\"\n                    Orientation=\"Vertical\"&gt;\n\n\n                    &lt;Entry\n                        IsVisible=\"{Binding IsLoggedIn, Converter={StaticResource InvertedBoolConverter}}\"\n                        HorizontalOptions=\"FillAndExpand\"\n                        Placeholder=\"Username\"\n                        Text=\"{Binding Username}\"\n                        x:Name=\"UsernameEntry\" \/&gt;\n\n                    &lt;Label\n                        IsVisible=\"{Binding IsLoggedIn}\"\n                        Text=\"{Binding Username}\"\n                        TextColor=\"#303030\"\n                        FontSize=\"12\"\n                        FontAttributes=\"Bold\"\n                        HeightRequest=\"40\"\n                        VerticalTextAlignment=\"Center\"\n                    \/&gt;\n\n                    &lt;Entry\n                        IsEnabled=\"{Binding CanSave}\"\n                        x:Name=\"EmailEntry\"\n                        HorizontalOptions=\"FillAndExpand\"\n                        Placeholder=\"Email\"\n                        Text=\"{Binding UserEmail}\" \/&gt;\n\n                &lt;\/StackLayout&gt;\n            &lt;\/StackLayout&gt;\n\n            &lt;Grid Margin=\"20, 0, 20, 0\"&gt;\n                &lt;Grid.RowDefinitions&gt;\n                    &lt;RowDefinition Height=\"53\" \/&gt;\n                    &lt;RowDefinition Height=\"53\" \/&gt;\n                    &lt;RowDefinition Height=\"60\" \/&gt;\n                    &lt;RowDefinition Height=\"28\" \/&gt;\n                    &lt;RowDefinition Height=\"*\" \/&gt;\n                    &lt;RowDefinition Height=\"45\" \/&gt;\n                &lt;\/Grid.RowDefinitions&gt;\n\n                &lt;Grid.ColumnDefinitions&gt;\n                    &lt;ColumnDefinition Width=\"1*\"\/&gt;\n                    &lt;ColumnDefinition Width=\"1*\"\/&gt;\n                &lt;\/Grid.ColumnDefinitions&gt;\n\n                &lt;Entry\n                    Grid.Row=\"0\" Grid.Column=\"0\"\n                    IsEnabled=\"{Binding CanSave}\"\n                    x:Name=\"FirstNameEntry\"\n                    HorizontalOptions=\"FillAndExpand\"\n                    Placeholder=\"First Name\"\n                    Text=\"{Binding FirstName}\" \/&gt;\n\n                &lt;Entry\n                    Grid.Row=\"0\" Grid.Column=\"1\"\n                    IsEnabled=\"{Binding CanSave}\"\n                    x:Name=\"LastNameEntry\"\n                    HorizontalOptions=\"FillAndExpand\"\n                    Placeholder=\"Last Name\"\n                    Text=\"{Binding LastName}\" \/&gt;\n                \n                &lt;Entry\n                    Grid.Row=\"1\" Grid.Column=\"0\"\n                    IsEnabled=\"{Binding CanSave}\"\n                    x:Name=\"PasswordEntry\"\n                    IsPassword=\"true\"\n                    HorizontalOptions=\"FillAndExpand\"\n                    Placeholder=\"Password\"\n                    Text=\"{Binding UserPassword}\" \/&gt;\n\n                &lt;Entry\n                    Grid.Row=\"1\" Grid.Column=\"1\"\n                    IsEnabled=\"{Binding CanSave}\"\n                    x:Name=\"ConfirmPasswordEntry\"\n                    IsPassword=\"true\"\n                    HorizontalOptions=\"FillAndExpand\"\n                    Placeholder=\"Confirm Password\"\n                    Text=\"{Binding ConfirmUserPassword, Mode=TwoWay}\" \/&gt;\n\n\n                &lt;Label\n                    Grid.Row=\"2\" Grid.ColumnSpan=\"2\"\n                    IsEnabled=\"{Binding CanSave}\"\n                    Margin=\"10\"\n                    Text=\"Password must be 8 digits long and include 1 number and 1 capital letter.\"\n                    TextColor=\"#303030\"\n                    FontSize=\"12\"\n                    HorizontalOptions=\"FillAndExpand\"\n                \/&gt;\n\n                &lt;views:StrengthIndicators \n                    IsEnabled=\"{Binding CanSave}\"\n                    Strength=\"{Binding PasswordStrength}\"\n                    HorizontalOptions=\"Center\" \n                    Grid.Row=\"3\" Grid.ColumnSpan=\"2\" \/&gt;\n\n                &lt;StackLayout\n                    Margin=\"0,20,0,40\"\n                    Grid.Row=\"4\" Grid.ColumnSpan=\"2\"\n                    IsVisible=\"{Binding IsLoggedIn}\"&gt;\n\n                    &lt;BoxView \n                        Margin=\"30,10\"\n                        BackgroundColor=\"#9B9B9B\"\n                        HorizontalOptions=\"FillAndExpand\"\n                        HeightRequest=\"1\"\n                        \/&gt;\n\n                    &lt;Label\n                        Text=\"Connected Accounts:\"\n                        HorizontalOptions=\"Center\"\n                        TextColor=\"#303030\"\n                        FontSize=\"12\"\/&gt;\n\n                    &lt;views:ConnectSocialButtonView  \n                        HorizontalOptions=\"Center\" \n                        BindingContext=\"{Binding FacebookVM}\" \/&gt;\n                \n                    &lt;views:ConnectSocialButtonView \n                        HorizontalOptions=\"Center\" BindingContext=\"{Binding TwitterVM}\" \/&gt;\n\n                    &lt;views:ConnectSocialButtonView \n                    HorizontalOptions=\"Center\" BindingContext=\"{Binding YouTubeVM}\" \/&gt;\n                \n                    &lt;views:ConnectSocialButtonView \n\n                    HorizontalOptions=\"Center\" BindingContext=\"{Binding InstagramVM}\" \/&gt;\n\n                &lt;\/StackLayout&gt;\n\n                &lt;Button\n                    Grid.Row=\"5\" Grid.ColumnSpan=\"2\"\n                    IsVisible=\"{Binding CanSave}\"\n                    HeightRequest=\"45\"\n                    x:Name=\"SaveButton\"\n                    Style=\"{StaticResource primaryButton}\"\n                    Text=\"        Submit        \"\n                    HorizontalOptions=\"Center\" \n                    Command=\"{Binding SaveCommand}\"&gt;\n                &lt;\/Button&gt;\n            &lt;\/Grid&gt;\n            &lt;\/StackLayout&gt;\n        &lt;\/ScrollView&gt;\n\n        &lt;\/StackLayout&gt;\n    &lt;\/ContentPage.Content&gt;\n&lt;\/ContentPage&gt;<\/pre>\n<p>Source: <a href=\"https:\/\/github.com\/davidortinau\/ProfileLayout\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/davidortinau\/ProfileLayout<\/a><\/p>\n<blockquote style=\"text-align: left;font-size: 12px;padding: 10px 20px;border-left: 3px solid blue\"><p>Note: this page is NOT optimized at all. In fact, you can probably point to many things that ought to be changed.<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>Compound this average layout with the need to create additional container renderers and wrappers for platform renderers, and it\u00a0results\u00a0in more views in your view tree than are necessary, approximately 130 for this example.<\/p>\n<p>Consider that performing layout requires child-to-parent recursion for measurement and then layout. The deeper\u00a0a UI nests (view within view within view), the more iterations are required. <em>Layout Compression<\/em>\u00a0allows you to specify unnecessary nesting and allows Xamarin.Forms to\u00a0opt-out of creating that layout view.<\/p>\n<p>Using <a href=\"https:\/\/developer.xamarin.com\/guides\/cross-platform\/inspector\/\" target=\"_blank\" rel=\"noopener noreferrer\">Xamarin Inspector<\/a> we can view the UI layering of this page\u00a0<strong>without<\/strong> <em>Layout Compression<\/em> or <em>Fast Renderers<\/em> enabled:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-33887\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/uncompressed.gif\" alt=\"\" width=\"333\" height=\"419\" \/><\/p>\n<p>Now enable Fast Renderers in the MainActivity.cs:<\/p>\n<pre class=\"marking:true lang:c# mark:7 decode:true \">public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity\n  {\n    protected override void OnCreate(Bundle bundle)\n    {\n      ...\n  \n      global::Xamarin.Forms.Forms.SetFlags(\"FastRenderers_Experimental\");\n      global::Xamarin.Forms.Forms.Init(this, bundle);\n\n      ...\n    }\n  }<\/pre>\n<p>&nbsp;<\/p>\n<p>And then enable <em>Layout Compression<\/em>. To enable <em>Layout Compression<\/em>, identify the layouts (StackLayout, AbsoluteLayout, Grid, RelativeLayout) to compress and add enable it with\u00a0CompressedLayout.IsHeadless=&#8221;true&#8221;. For example:<\/p>\n<pre class=\"marking:true lang:xhtml mark:3 decode:true\">&lt;StackLayout\n            Spacing=\"0\"\n            CompressedLayout.IsHeadless=\"true\"\n            VerticalOptions=\"FillAndExpand\"\n            HorizontalOptions=\"FillAndExpand\"&gt;\n...\n&lt;\/StackLayout&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>Now take a look at the\u00a0layout tree layering:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-33886\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/compressed.gif\" alt=\"\" width=\"331\" height=\"416\" \/><\/p>\n<p>The improvement in these visuals is obvious. I&#8217;ll save you some counting to see how much we were able to flatten the UI.<\/p>\n<ul>\n<li><strong>Default:<\/strong> 130 Renderers<\/li>\n<li><strong>Layout Compression:<\/strong> 111 Renderers<\/li>\n<li><strong>Layout Compression + Fast Renderers:<\/strong> 70 Renderers<\/li>\n<\/ul>\n<p>The question naturally becomes, \u201chow much faster does this make my application?\u201d This will vary depending on the complexity of your view, the version of the operating system you\u2019re using, and the device on which it\u2019s running. While everyone benefits, we expect to see the biggest difference on older devices.<\/p>\n<p>Because layout compression eliminates the renderer for the layout, note that anything you previously expect to be\u00a0part of that renderer will no longer be present:<\/p>\n<ul>\n<li>Background color<\/li>\n<li>Gestures<\/li>\n<li>Transformations<\/li>\n<li>etc.<\/li>\n<\/ul>\n<p>Layout Compression is available on iOS and Android.<\/p>\n<h3>Big Thing 2: Forms Embedding<\/h3>\n<p>At Build 2017 we <a href=\"https:\/\/blog.xamarin.com\/unleashed-embedding-xamarin-forms-in-xamarin-native\/\" target=\"_blank\" rel=\"noopener noreferrer\">showcased taking a Xamarin.Forms<\/a> <code>ContentPage<\/code> and embedding it in native Xamarin.iOS, Xamarin.Android, and UWP applications. Even with that being a very early preview, it didn&#8217;t stop many of you from exploring the possibilities. Since then, we&#8217;ve been cleaning up the implementation, resolving issues found in our early testing (thank you early adopters!), and validating our use cases for this new capability. <\/p>\n<p>What might you want to do with this?<\/p>\n<ul>\n<li>Take an existing Xamarin.Forms page and use it in another Xamarin iOS, Android, or UWP application that doesn\u2019t use Xamarin.Forms.<\/li>\n<li>Start a project using Xamarin.Forms for the speed and ease of delivering a prototype, and then migrate it page by page to Xamarin native\/<\/li>\n<li>Add shared pages to any existing Xamarin application which changing the entire architecture.<\/li>\n<\/ul>\n<p>And that&#8217;s just the beginning. Now there&#8217;s no question whether to\u00a0start with Xamarin.Forms. Use Xamarin.Forms\u00a0everywhere it&#8217;s suitable in your applications!<\/p>\n<h3>Big Thing 3: Improved macOS Desktop Support<\/h3>\n<p>Xamarin.Forms has grown up in mobile, and extending to desktop paradigms is a process. In Xamarin.Forms 2.4.0, we introduced <a href=\"https:\/\/developer.xamarin.com\/guides\/xamarin-forms\/platform-features\/mac\/\" target=\"_blank\" rel=\"noopener noreferrer\">a preview of macOS support<\/a>, and I&#8217;ve already seen some impressive applications from you. <a href=\"https:\/\/forums.xamarin.com\/93585\/preview-xamarin-forms-for-macos\" target=\"_blank\" rel=\"noopener noreferrer\">Your feedback<\/a> has helped identify where we most needed to increase support, so in 2.5.0 you&#8217;re getting:<\/p>\n<h4>App Exit<\/h4>\n<p>From anywhere in your application, you can call <code>Application.Current.Quit()<\/code> to quit.<\/p>\n<h4>Menus<\/h4>\n<p>Desktop applications can handle menus differently than touch or mobile applications. In this preview, you can now add context menus on right click, as well as attaching menus to the top level of your application so they appear in the top bar on macOS.<\/p>\n<p>For example, below we construct a menu in C# and attach it to a Label in our view. Right clicking the Label will now open the context menu.<\/p>\n<pre class=\"EnlighterJSRAW\">var mainMenu = new Menu();\nvar locationMenu = new Menu { Text = \u201cLocation\u201d };\nvar changeItem = new MenuItem\n{\nText = \u201cChange\u201d,\nCommand = new Command((obj) =&gt;\n{\nNavigation.PushModalAsync(new LocationEntryPage());\n})\n};\nlocationMenu.Items.Add(changeItem);\n\nvar refreshItem = new MenuItem { Text = \"Refresh\", Command = _vm.ReloadCommand }; MenuItem.SetAccelerator(refreshItem, Accelerator.FromString(\"cmd+r\")); locationMenu.Items.Add(refreshItem); mainMenu.Add(locationMenu); \/\/ Context Menu SetMenu(ConditionLabel, mainMenu);<\/pre>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-33888\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/context-menu.gif\" alt=\"\" width=\"513\" height=\"425\" \/><\/p>\n<p>Source:\u00a0<a href=\"https:\/\/github.com\/davidortinau\/weather-app\/tree\/macos-and-location\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/davidortinau\/weather-app\/tree\/macos-and-location<\/a><\/p>\n<h4>Accelerators<\/h4>\n<p>Accelerators, also known as key modifiers, allow you to add keyboard shortcuts to activate menu items. In this example, we&#8217;re adding the <code>cmd+R<\/code> accelerator to the refresh menu item.<\/p>\n<pre class=\"EnlighterJSRAW\">MenuItem.SetAccelerator(refreshItem, Accelerator.FromString(\"cmd+r\"));<\/pre>\n<p>Then the accelerator is added to a top level menu item, and is available to use from anywhere in the application.<\/p>\n<h3>Preview Today!<\/h3>\n<p>Xamarin.Forms 2.5.0.19271 is available now on NuGet. To update, open your NuGet package manager, enable the Pre-Release option, and update all of your project references.<\/p>\n<blockquote style=\"text-align: left;font-size: 12px;padding: 10px 20px;border-left: 3px solid blue\"><p><b>What&#8217;s with the new version numbers?<\/b>\nOur builds are now being generated from Visual Studio Team Services which simply generates a different build number.<\/p><\/blockquote>\n<p>Your participation in our pre-releases are essential. Please let us know about any issues you find by <a href=\"https:\/\/bugzilla.xamarin.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">filing detailed reports in Bugzilla<\/a>. <\/p>\n<p><a href=\"https:\/\/forums.xamarin.com\/105475\/pre-release-xamarin-forms-2-5-0-19271-pre2#latest\" target=\"_blank\" rel=\"noopener noreferrer\">Discuss this post in the forums!<\/a>\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the past year we\u2019ve been working on a couple of &#8220;big things&#8221; that enable you to create more performant applications on more platforms. With our latest stable release, version 2.4.0, we introduced performance optimized renderers on Android,\u00a0nicknamed Fast Renderers. While faster platform renderers are a clear win, you really start to see the big [&hellip;]<\/p>\n","protected":false},"author":553,"featured_media":33887,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[16],"class_list":["post-33882","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-xamarin-forms"],"acf":[],"blog_post_summary":"<p>Over the past year we\u2019ve been working on a couple of &#8220;big things&#8221; that enable you to create more performant applications on more platforms. With our latest stable release, version 2.4.0, we introduced performance optimized renderers on Android,\u00a0nicknamed Fast Renderers. While faster platform renderers are a clear win, you really start to see the big [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/33882","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=33882"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/33882\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=33882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=33882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=33882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}