{"id":45097,"date":"2019-08-15T13:51:18","date_gmt":"2019-08-15T20:51:18","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/xamarin\/?p=45097"},"modified":"2020-01-08T12:20:47","modified_gmt":"2020-01-08T20:20:47","slug":"public-preview-xaml-hot-reload-xamarin-forms","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/public-preview-xaml-hot-reload-xamarin-forms\/","title":{"rendered":"Public Preview of XAML Hot Reload for Xamarin.Forms"},"content":{"rendered":"<p><strong>1\/8\/2020: XAML Hot Reload is now stable in both Visual Studio and Visual Studio for Mac! Learn more about it in our <a href=\"https:\/\/aka.ms\/XAMLHotReloadDocs\">documentation<\/a>.<\/strong><\/p>\n<p><span style=\"font-size: 1rem;\">As a developer, we often get into a cycle of running an app, noticing that some adjustment needs to be made, stopping the app, estimating the adjusted values, and then repeating the whole process over again to see if the estimate was correct. We call this the \u201cinner development loop,\u201d and it can quickly become quite tedious.<\/span><\/p>\n<h2>Public Preview of XAML Hot Reload for Xamarin.Forms<\/h2>\n<p>A few days ago, <a href=\"https:\/\/devblogs.microsoft.com\/xamarin\/visual-studio-2019-previews\/\">we announced<\/a> the release of the latest Visual Studio and Visual Studio for Mac previews. One of the exciting new features included in this release is a public preview of <a href=\"https:\/\/devblogs.microsoft.com\/xamarin\/xaml-hot-reload\/\">XAML Hot Reload for Xamarin.Forms<\/a>. We hope this feature will dramatically speed up your inner development loop when working with Xamarin.Forms XAML. XAML Hot Reload instantly reflects changes you make in your running app, without requiring you to stop and rebuild.<\/p>\n<p>Here&#8217;s an example of Hot Reload in action:<\/p>\n<p><center>\n<iframe width=\"560\" height=\"315\" src=\"\/\/www.youtube.com\/embed\/Iu-JFCSkKUc\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"allowfullscreen\" data-mce-fragment=\"1\"><\/iframe><\/center><\/p>\n<h2>Enabling XAML Hot Reload<\/h2>\n<blockquote><p>See the documentation for XAML Hot Reload for Xamarin.Forms at <a href=\"https:\/\/aka.ms\/XAMLHotReloadDocs\">https:\/\/aka.ms\/XAMLHotReloadDocs<\/a>.<\/p><\/blockquote>\n<p>As a preview feature, XAML Hot Reload for Xamarin.Forms is currently disabled by default when you first update to the latest preview of Visual Studio 2019 or Visual Studio 2019 for Mac. Follow these steps to enable it:<\/p>\n<ol>\n<li>Ensure you have installed the latest version of Visual Studio that includes XAML Hot Reload:\n<ul>\n<li><a href=\"https:\/\/visualstudio.microsoft.com\/vs\/\">Visual Studio 2019 16.3<\/a><\/li>\n<li><a href=\"https:\/\/visualstudio.microsoft.com\/vs\/mac\/\">Visual Studio 2019 for Mac 8.3<\/a><\/li>\n<\/ul>\n<\/li>\n<li>Enable Xamarin XAML Hot Reload in the settings screen:\n<ul>\n<li>On Windows, XAML Hot Reload can be enabled by checking the <strong style=\"font-size: 1rem;\">Enable Xamarin Hot Reload<\/strong><span style=\"font-size: 1rem;\">\u00a0checkbox at:\n<\/span><strong style=\"font-size: 1rem;\">Tools<\/strong><span style=\"font-size: 1rem;\">\u00a0&gt;\u00a0<\/span><strong style=\"font-size: 1rem;\">Options<\/strong><span style=\"font-size: 1rem;\">\u00a0&gt;\u00a0<\/span><strong style=\"font-size: 1rem;\">Xamarin<\/strong><span style=\"font-size: 1rem;\">\u00a0&gt;\u00a0<\/span><strong style=\"font-size: 1rem;\">Hot Reload<\/strong><span style=\"font-size: 1rem;\">.\n<strong style=\"font-size: 1rem;\">\u00a0 \u00a0 <img decoding=\"async\" class=\"alignnone wp-image-45099\" src=\"http:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/08\/Screen-Shot-2019-08-15-at-1.43.31-PM.png\" alt=\"Public Preview of XAML Hot Reload for Xamarin.Forms Windows\" width=\"504\" height=\"446\" srcset=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/08\/Screen-Shot-2019-08-15-at-1.43.31-PM.png 790w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/08\/Screen-Shot-2019-08-15-at-1.43.31-PM-300x265.png 300w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/08\/Screen-Shot-2019-08-15-at-1.43.31-PM-768x680.png 768w\" sizes=\"(max-width: 504px) 100vw, 504px\" \/><\/strong><\/span><\/li>\n<li>On a Mac, XAML Hot Reload can be enabled by checking the\u00a0<strong style=\"font-size: 1rem;\">Enable Xamarin Hot Reload<\/strong><span style=\"font-size: 1rem;\">\u00a0checkbox at:\n<\/span><strong style=\"font-size: 1rem;\">Visual Studio<\/strong><span style=\"font-size: 1rem;\">\u00a0&gt;\u00a0<\/span><strong style=\"font-size: 1rem;\">Preferences<\/strong><span style=\"font-size: 1rem;\">\u00a0&gt;\u00a0<\/span><strong style=\"font-size: 1rem;\">Projects<\/strong><span style=\"font-size: 1rem;\">\u00a0&gt;\u00a0<\/span><strong style=\"font-size: 1rem;\">Xamarin Hot Reload.\n<img decoding=\"async\" class=\"alignnone wp-image-45101\" src=\"http:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/08\/Screen-Shot-2019-08-15-at-1.49.48-PM.png\" alt=\"Public Preview of XAML Hot Reload for Xamarin.Forms Mac\" width=\"602\" height=\"457\" srcset=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/08\/Screen-Shot-2019-08-15-at-1.49.48-PM.png 1072w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/08\/Screen-Shot-2019-08-15-at-1.49.48-PM-300x228.png 300w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/08\/Screen-Shot-2019-08-15-at-1.49.48-PM-768x583.png 768w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2019\/08\/Screen-Shot-2019-08-15-at-1.49.48-PM-1024x778.png 1024w\" sizes=\"(max-width: 602px) 100vw, 602px\" \/>\n<\/strong><\/li>\n<\/ul>\n<\/li>\n<li>Debug your Xamarin.Forms Android or iOS app and edit a XAML file while your app is running. The changes will automatically be applied to the running app when you hit Save.<\/li>\n<\/ol>\n<p><strong>Note:<\/strong> If you were a part of the private preview, additional information on upgrading to the public preview can be found <a href=\"https:\/\/docs.microsoft.com\/xamarin\/xamarin-forms\/xaml\/hot-reload?WT.mc_id=hrpreview-xamarinblog-maleger#migrate-from-the-private-preview\">here<\/a>.<\/p>\n<h2>How does it Work?<\/h2>\n<p>Before going wild trying to reload everything, it&#8217;s important to understand the functionality and limitations of XAML Hot Reload for Xamarin.Forms. When you save changes to a Xamarin.Forms XAML file, XAML Hot Reload jumps into action:<\/p>\n<ol>\n<li>First, XAML Hot Reload identifies the runtime object that corresponds to the top-level object of the XAML file that was edited. If the view or page is not currently loaded, the change is saved for later.<\/li>\n<li>The Xamarin.Forms XAML loader is run again on the existing object, resetting its properties and recreating its children from the changed XAML file.<\/li>\n<li>The <code>InitializeComponent<\/code> method is called again on the object to re-connect the newly inflated objects to any event handlers or <code>x:Name<\/code> properties you might have in your code behind.<\/li>\n<\/ol>\n<p>As you might guess, this approach carries with it some limitations:<\/p>\n<ol>\n<li><strong>Code and resource changes are not reloaded.<\/strong> You can only reload changes to XAML. Changes to your code, (including things like adding new event handlers, or resources, such as images or CSS) will not be reloaded.<\/li>\n<li><strong>Some view state may be lost on reload. <\/strong>If you are modifying the appearance or style of your views in code as well as XAML, those modifications may not be re-applied after a reload. This is because the code might not be re-run on the newly inflated XAML objects.<\/li>\n<\/ol>\n<p>A more comprehensive list of <a href=\"https:\/\/docs.microsoft.com\/xamarin\/xamarin-forms\/xaml\/hot-reload?WT.mc_id=hrpreview-xamarinblog-maleger#known-limitations\">Known Limitations<\/a> is available on the documentation site. In most cases, XAML Hot Reload is resilient enough to handle unsupported changes gracefully. It will indicate invalid XAML or other issues with IntelliSense as you edit your XAML file.<\/p>\n<p>For a better reload experience, we are working to remove some of these limitations while preserving more of your view state. Be the first to receive improvement updates by staying up to date with the latest preview releases!<\/p>\n<h2>We Want your Feedback on this Public Preview!<\/h2>\n<p>We&#8217;ve released XAML Hot Reload for Xamarin.Forms as a preview feature to start improving your inner development loop today. Our future roadmap is driven by your feedback and needs. So try it out and let us know if it makes your life easier. Or if there is anything we can do to make XAML Hot Reload even better! Here are some of the top suggestions we&#8217;ve received already:<\/p>\n<ul>\n<li><a href=\"https:\/\/developercommunity.visualstudio.com\/content\/problem\/694150\/allow-hotreload-on-multiple-devicesemulators-at-th.html\">Allow XAML Hot Reload on multiple devices\/emulators at the same time<\/a><\/li>\n<li><a href=\"https:\/\/developercommunity.visualstudio.com\/idea\/650688\/hot-reload-for-xamarinandroid.html\">Hot Reload for Xamarin.Android<\/a><\/li>\n<li><a href=\"https:\/\/developercommunity.visualstudio.com\/idea\/661682\/xaml-hot-reload-for-xamarinforms-on-uwp.html\">XAML Hot Reload for Xamarin.Forms on UWP<\/a><\/li>\n<li><a href=\"https:\/\/developercommunity.visualstudio.com\/idea\/650684\/c-hot-reload-xamarin.html\">Xamarin Hot Reload for C#<\/a><\/li>\n<\/ul>\n<p>If any of those suggestions are important to you, please let us know by up voting them. To report a new bug or suggested feature, use the feedback tool at the <strong>Help<\/strong>\u00a0&gt;\u00a0<strong>Send Feedback<\/strong>\u00a0&gt;\u00a0<strong>Report a Problem<\/strong>\u00a0menu on Windows, and the\u00a0<strong>Help<\/strong>\u00a0&gt;\u00a0<strong>Report a Problem<\/strong> menu on a Mac. Or reach out to us on Twitter at <a href=\"https:\/\/twitter.com\/chknofthescene\">@chknofthescene<\/a> or <a href=\"https:\/\/twitter.com\/maddyleger1\">@maddyleger1<\/a>. We hope to hear from you!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Along with Visual Studio and Visual Studio for Mac previews, this release also has a public preview of XAML Hot Reload for Xamarin.Forms to speed up your inner development loop when working with Xamarin.Forms XAML by instantly reflecting changes you make in your running app, without requiring you to stop and rebuild.<\/p>\n","protected":false},"author":566,"featured_media":45117,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5216,2,367],"tags":[6664,6603,6663,5841,6604],"class_list":["post-45097","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcements","category-developers","category-xamarin-forms","tag-mac","tag-preview","tag-windows","tag-xaml","tag-xaml-hot-reload"],"acf":[],"blog_post_summary":"<p>Along with Visual Studio and Visual Studio for Mac previews, this release also has a public preview of XAML Hot Reload for Xamarin.Forms to speed up your inner development loop when working with Xamarin.Forms XAML by instantly reflecting changes you make in your running app, without requiring you to stop and rebuild.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/45097","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\/566"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=45097"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/45097\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/45117"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=45097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=45097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=45097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}