{"id":45593,"date":"2020-10-09T08:55:49","date_gmt":"2020-10-09T08:55:49","guid":{"rendered":"https:\/\/www.bridge-global.com\/blog\/?p=45593"},"modified":"2020-10-12T03:58:19","modified_gmt":"2020-10-12T03:58:19","slug":"xamarin-forms-styling-using-material-visual","status":"publish","type":"post","link":"https:\/\/www.bridge-global.com\/blog\/xamarin-forms-styling-using-material-visual\/","title":{"rendered":"How to Style Xamarin.Forms Using Material Visual"},"content":{"rendered":"\n<p>This is the most comprehensive guide to Xamarin.Forms style using material visual.<\/p>\n\n\n\n<p>In this new guide, you\u2019ll learn how to apply Material Design rules to Xamarin applications.<\/p>\n\n\n\n<p>Let\u2019s dive right in:<\/p>\n\n\n\n<p>Getting mobile apps into the hands of target users is a never-ending dream of businesses worldwide. <\/p>\n\n\n\n<p>But creating apps that span all mobile platforms.is a challenge for developers especially when it comes to creating apps using Xamarin &#8211; the renowned open-source mobile app platform for NET.<\/p>\n\n\n\n<p>The shattered landscape of mobile platforms poses a real challenge when it comes to rendering an apt look and feel (style) to Xamarin apps across diverse platforms. <\/p>\n\n\n\n<p>Here, you can get some useful tips to build amazing cross-platform iOS, Android, and Windows applications in .NET.<\/p>\n\n\n\n<p>Let&#8217;s discover how to make your app look more similar across-platform using the Xamarin Visual Rendering System. Xamarin.Forms just uses the native controls undercover, which is indeed an adorable thing. <\/p>\n\n\n\n<p>So if you build a settings page on <a href=\"https:\/\/www.bridge-global.com\/services\/mobile-application-development\/android-application-development\">Android<\/a> and a settings page on <a href=\"https:\/\/www.bridge-global.com\/services\/mobile-application-development\/ios-application-development\">iOS<\/a>,as the operating systems update, your controls are going to get updated and they are going to look like how the operating system thinks modern controls should look.&nbsp;&nbsp;<\/p>\n\n\n\n<p>Styles are great. You just customize the control as heavily as you need to. You can change any property and apply it through your app. For more information refer <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/get-started\/quickstarts\/styling?pivots=windows&amp;WT.mc_id=xamarin-c9-maleger\" target=\"_blank\" rel=\"noreferrer noopener nofollow\" class=\"rank-math-link\">Styles<\/a>.<br \/><\/p>\n\n\n\n<p>But there&#8217;s another way that you can do it where you hook into an existing design system: by using the Xamarin Visual Rendering System.<\/p>\n\n\n\n<p>You can actually create your own design system with the Visual Rendering System. It&#8217;s shareable with different apps as well. <\/p>\n\n\n\n<p>But the really cool thing about the visual system is that you can pull in existing design systems from open source. <\/p>\n\n\n\n<p>One of those is <a aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener nofollow\" href=\"https:\/\/material.io\/design\" target=\"_blank\" class=\"rank-math-link\">Material Design<\/a> &#8211; Google&#8217;s design system. It is very popular and this is what they use for all their apps right now. <\/p>\n\n\n\n<p>So if you open Google Maps on Android and iOS, they look pretty similar and that&#8217;s because they are using Material Design renders on those platforms.<\/p>\n\n\n\n<p>Xamarin has introduced <a aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener nofollow\" href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/xamarin-forms\/user-interface\/visual\/material-visual\" target=\"_blank\" class=\"rank-math-link\">Xamarin.Forms Material Visual<\/a>, which can be used to apply Material Design rules to Xamarin applications. <\/p>\n\n\n\n<p>If we enable Material Visual , the supported views will adopt the same designs cross-platform, resulting in a unified look and feel.<\/p>\n\n\n\n<h2>3 Simple steps to add Xamarin.Forms Material Visual in your application.<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Add the Xamarin.Forms.Visual.Material NuGet package to Android and iOS platform projects. This NuGet package delivers optimized Material Design renderers on iOS and Android.<\/li><li>Initialize Material Visual in each platform project.<\/li><li>Create Material Visual controls by setting the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/xamarin.forms.visualelement.visual?view=xamarin-forms#Xamarin_Forms_VisualElement_Visual\" target=\"_blank\">Visual Property<\/a>&nbsp;to Material on any pages that should adopt the Material Design rules.<\/li><\/ul>\n\n\n\n<p><strong>Material Visual Initialization<\/strong><br \/>After installing Material Visual, it should be rendered to each platform project.<br \/>On Android, you can add the Xamarin.Forms.FormsMaterial.Init method <strong>MainActivity<\/strong>. Cs after the Xamarin.Forms.Forms.Init method:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"512\" height=\"159\" src=\"https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-1.jpg\" alt=\"Material Visual Initialization Xamarin\" class=\"wp-image-45598\" srcset=\"https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-1.jpg 512w, https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-1-300x93.jpg 300w, https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-1-500x155.jpg 500w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p>On iOS, this can be done in <strong>AppDelegate.cs<\/strong> by invoking the Xamarin.Forms.FormsMaterial.Init method after the Xamarin.Forms.Forms.Init method:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"512\" height=\"154\" src=\"https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-2.jpg\" alt=\"Apply Material Visual to pages\" class=\"wp-image-45599\" srcset=\"https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-2.jpg 512w, https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-2-300x90.jpg 300w, https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-2-500x150.jpg 500w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p><strong>Apply Material Visual to pages<\/strong><\/p>\n\n\n\n<p>The <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/xamarin.forms.visualelement.visual?view=xamarin-forms#Xamarin_Forms_VisualElement_Visual\" target=\"_blank\" rel=\"noreferrer noopener nofollow\" class=\"rank-math-link\">VisualElement.Visual property<\/a> on a page layout will help you to enable Material Visual on your page or on any layout or view.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"512\" height=\"156\" src=\"https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-3.jpg\" alt=\"Apply Material Visual to pages Xamarin\" class=\"wp-image-45600\" srcset=\"https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-3.jpg 512w, https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-3-300x91.jpg 300w, https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-3-500x152.jpg 500w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p>The equivalent C# code is:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"512\" height=\"166\" src=\"https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-4.jpg\" alt=\"Apply Material Visual to pages Xamarin\" class=\"wp-image-45601\" srcset=\"https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-4.jpg 512w, https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-4-300x97.jpg 300w, https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/Xamarin-code-4-500x162.jpg 500w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p>If we set the VisualElement.Visual property to Material then the application will use the Material Visual renderers instead of the default renderers. <\/p>\n\n\n\n<p>The values of Visual property can be set to <strong>Default, MatchParent or Material<\/strong>.<\/p>\n\n\n\n<p><strong>Default<\/strong> indicates that the view should render using the default renderer.<br \/><strong>MatchParent<\/strong> will be the best option if the view should render like its direct parent.<br \/><strong>Material <\/strong>refers that the view can be rendered with the help of Material renderer.<\/p>\n\n\n\n<p>For more information refer <a href=\"https:\/\/docs.microsoft.com\/en-us\/xamarin\/xamarin-forms\/user-interface\/visual\/material-visual?WT.mc_id=xamarin-c9-maleger\" target=\"_blank\" aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener nofollow\" class=\"rank-math-link\">this Link<\/a>.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Get quick insights into how to make your app look more similar across platforms using the Xamarin Visual Rendering System.<br \/>\n<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":106,"featured_media":45693,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[152,314,315,316],"class_list":["post-45593","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-microsoft-professionals","tag-xamarin","tag-technology","tag-software-development"],"featured_image_src":"https:\/\/www.bridge-global.com\/blog\/wp-content\/uploads\/2020\/10\/How-to-Apply-Material-Design-Rules-to-Xamarin-Applications-1-2.png","author_info":{"display_name":"Blessy Alexander","author_link":"https:\/\/www.bridge-global.com\/blog\/author\/blessy-alexander\/"},"_links":{"self":[{"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/posts\/45593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/users\/106"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/comments?post=45593"}],"version-history":[{"count":23,"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/posts\/45593\/revisions"}],"predecessor-version":[{"id":45719,"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/posts\/45593\/revisions\/45719"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/media\/45693"}],"wp:attachment":[{"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/media?parent=45593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/categories?post=45593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bridge-global.com\/blog\/wp-json\/wp\/v2\/tags?post=45593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}