{"id":35706,"date":"2018-02-23T14:24:57","date_gmt":"2018-02-23T19:24:57","guid":{"rendered":"https:\/\/blog.xamarin.com\/?p=35706"},"modified":"2018-02-23T14:24:57","modified_gmt":"2018-02-23T19:24:57","slug":"add-tizen-projects-xamarin-forms-apps","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/add-tizen-projects-xamarin-forms-apps\/","title":{"rendered":"Add Tizen Projects to Your Xamarin.Forms Applications"},"content":{"rendered":"<p>\t\t\t\t<em>This is a special guest post from Jay Cho of the Samsung Tizen team.<\/em><\/p>\n<p>It&#8217;s been a while since the first preview version of Tizen .NET was released. Thanks to the newest release, developing Xamarin.Forms applications with Tizen projects has never been so easy. Using the familiar Visual Studio IDE, you can now develop applications by installing the extension <em>Visual Studio Tools for Tizen<\/em>, and use Xamarin.Forms as the UI framework. This new way of developing applications is a great opportunity, not only for existing Tizen developers, but for all Xamarin developers.<\/p>\n<blockquote style=\"text-align: left;font-size: medium;padding: 10px 20px;border-left: 3px solid #2c3e50\"><p><b>Prerequisites<\/b>: If you&#8217;re brand new to developing Tizen .NET applications, start by browsing the <a href=\"https:\/\/developer.tizen.org\/development\/guides\/.net-application\">Tizen development guides<\/a> and learn <a href=\"https:\/\/developer.tizen.org\/development\/visual-studio-tools-tizen\/installing-visual-studio-tools-tizen\">how to install the Tizen SDK, emulators, and tools<\/a>.<\/p><\/blockquote>\n<p>If you already have your own cross-platform Xamarin apps, or if you&#8217;re about to create a new one, it&#8217;s definitely worth adding a Tizen project. Your apps can run on many profiles of Tizen devices, such as mobile, TV, and wearables. Below, I&#8217;ll show you how it&#8217;s done.<\/p>\n<h2 id=\"addtizenproject\">Add a Tizen Project<\/h2>\n<h3 id=\"onvisualstudio\">On Visual Studio<\/h3>\n<p>As an example, below is a sample cross-platform app named <em>SimpleText<\/em>, which shows a simple line of text in the center. The text varies depending on the <strong>Platform<\/strong> and <strong>Idiom<\/strong>:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-35714\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/Android.png\" alt=\"\" width=\"250\" height=\"500\" \/><\/p>\n<p align=\"center\">On an Android Emulator, you&#8217;ll see the text displayed as &#8220;Welcome to Xamarin.Forms.Android!&#8221;.<\/p>\n<p>&nbsp;\n<img decoding=\"async\" class=\"aligncenter wp-image-35707\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/iOS.png\" alt=\"\" width=\"356\" height=\"500\" \/><\/p>\n<p align=\"center\">On an iOS Simulator, the text is replaced with, &#8220;Welcome to Xamarin.Forms.iOS!&#8221;.<\/p>\n<p>&nbsp;\nTo run on the Tizen platform in Visual Studio:<\/p>\n<ul>\n<li>Go to <strong>File -&gt; Add -&gt; New Project<\/strong>.<\/li>\n<li>Select the Tizen cross-platform template <strong>Visual C# -&gt; Tizen -&gt; Blank App (Xamarin.Forms)<\/strong><\/li>\n<li>Give your project the name <code>SimpleText.Tizen<\/code>.<\/li>\n<\/ul>\n<p>To run the Tizen project Wizard:<\/p>\n<ul>\n<li>Select &#8220;Common&#8221; as the <em>Profile<\/em>. For future projects, the available profiles are Mobile, TV, and Wearable.<\/li>\n<li>Choose <em>Select Project in Solution<\/em>.<\/li>\n<li>Select <em>SimpleText<\/em> as the reference. The ability to select an existing reference is included in version 1.2.0 of Visual Studio Tools for Tizen.<\/li>\n<li>Add code <code>LoadApplication(new SimpleText.App())<\/code> to the <strong>SimpleText.Tizen\/SimpleText.Tizen.cs<\/strong> file<\/li>\n<\/ul>\n<pre class=\"lang:csharp decode:true \">namespace SimpleText.Tizen\n{\n  class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication\n  {\n      protected override void OnCreate()\n      {\n          base.OnCreate();\n          LoadApplication(new SimpleText.App());\n      }\n\n  static void Main(string[] args)\n  {\n      var app = new Program();\n      global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);\n      app.Run(args);\n  }\n  }\n}\n<\/pre>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-35713\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/Demo.gif\" alt=\"\" width=\"800\" height=\"559\" \/><\/p>\n<h3>View and Check the Reference<\/h3>\n<p>View the results and see if the generated Tizen project refers to the correct reference as a dependency:<\/p>\n<p><img decoding=\"async\" class=\"alignright size-full wp-image-35712\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/SolutionExplorer.png\" alt=\"\" width=\"406\" height=\"393\" \/><\/p>\n<p>Instead of adding a stable version of Xamarin.Forms NuGet package, you should use the <a href=\"https:\/\/www.myget.org\/feed\/xamarinforms-ci\/package\/nuget\/Xamarin.Forms\">Nightly Build<\/a>, or the <a href=\"https:\/\/www.nuget.org\/packages\/Xamarin.Forms.Platform.Tizen\/\">Xamarin.Forms.Platform.Tizen package<\/a> as a reference at this time. Version 2.5.0.77107 of Xamarin.Forms.Platform.Tizen works beautifully.<\/p>\n<p>When the Tizen renderers are shipped with Xamarin.Forms in the future, you&#8217;ll only need to use the stable version of Xamarin.Forms. Tizen renderer code has been merged into Xamarin.Forms and is presently available for preview in <strong>Nightly Builds<\/strong>.<\/p>\n<p>There&#8217;s another significant package called <strong>Tizen.NET<\/strong> that allows your app to use the Tizen platform-specific APIs, which include all of the Tizen features, and will help your app do everything a Tizen native application can do. Visit the <a href=\"https:\/\/developer.tizen.org\/dev-guide\/csapi\/index.html\">Tizen developer guide<\/a> to see which Tizen APIs are provided.<\/p>\n<blockquote style=\"text-align: left;font-size: 12px;padding: 10px 20px;border-left: 3px solid #2c3e50\"><p>Check out <a href=\"https:\/\/github.com\/xamarin\/xamarin-forms-samples\/pull\/245\">these Xamarin.Forms samples<\/a> to see how Tizen APIs are being added to tons of existing Xamarin projects.<\/p><\/blockquote>\n<h3 id=\"onvisualstudioformac\">On Visual Studio for Mac<\/h3>\n<p>If you&#8217;re using Mac, Tizen projects may not run, since it can&#8217;t recognize &#8216;Tizen 4.0&#8217; as the target framework yet. If this happens, try installing <a href=\"https:\/\/github.com\/mrward\/temp-addin-upload\/tree\/master\/DotNetCoreSupportAnyTargetFramework\">this add-in<\/a> to support Tizen projects on Visual Studio for Mac.<\/p>\n<h2 id=\"howtogetatypeofosoridiom\">How to get a type of OS or Idiom<\/h2>\n<p>The <code>Xamarin.Forms.Device<\/code> class may be familiar to most Xamarin developers, as it provides useful public properties such as <code>RuntimePlatform<\/code> and <code>Idiom<\/code>. Those properties provide the OS and device to run on. In the <em>SimpleText<\/em> app, platforms and target devices are separated on the code, as below. See how the C# code is implemented, as well:<\/p>\n<pre class=\"lang:Xaml decode:true \">&lt;?xml version=\"1.0\" encoding=\"utf-8\" ?&gt;\n&lt;ContentPage xmlns=\"http:\/\/xamarin.com\/schemas\/2014\/forms\"\n             xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2009\/xaml\"\n             xmlns:local=\"clr-namespace:SimpleText\"\n             x:Class=\"SimpleText.MainPage\"&gt;\n    &lt;Label VerticalOptions=\"Center\" HorizontalOptions=\"Center\" FontSize=\"Large\" FontAttributes=\"Bold\"&gt;\n        &lt;Label.Text&gt;\n            &lt;OnPlatform x:TypeArguments=\"x:String\"&gt;\n                &lt;On Platform=\"Android\" Value=\"Welcome to Xamarin.Forms.Android!\" \/&gt;\n                &lt;On Platform=\"iOS\" Value=\"Welcome to Xamarin.Forms.iOS!\" \/&gt;\n                &lt;On Platform=\"UWP\" Value=\"Welcome to Xamarin.Forms.UWP!\" \/&gt;\n                &lt;On Platform=\"Tizen\"&gt;\n                    &lt;On.Value&gt;\n                        &lt;OnIdiom x:TypeArguments=\"x:String\"&gt;\n                            &lt;OnIdiom.Phone&gt;Welcome to Xamarin.Forms.Tizen-Mobile&lt;\/OnIdiom.Phone&gt;\n                            &lt;OnIdiom.TV&gt;Welcome to Xamarin.Forms.Tizen-TV&lt;\/OnIdiom.TV&gt;\n                        &lt;\/OnIdiom&gt;\n                    &lt;\/On.Value&gt;\n                &lt;\/On&gt;\n            &lt;\/OnPlatform&gt;\n        &lt;\/Label.Text&gt;\n    &lt;\/Label&gt;\n&lt;\/ContentPage&gt;<\/pre>\n<p>You can try using <code>TargetIdiom.Unsupported<\/code> to test the code here on the Tizen wearable emulator. The idiom for the wearable device isn&#8217;t yet defined in Xamarin.Forms, but we expect to add this in the near future.<\/p>\n<pre class=\"lang:csharp decode:true \">using Xamarin.Forms;\n\nnamespace SimpleText\n{\n    class MainPageCS : ContentPage\n    {\n        public MainPageCS()\n        {\n            Content = new StackLayout\n            {\n                VerticalOptions = LayoutOptions.Center,\n                Children =\n                {\n                        new Label\n                        {\n                            HorizontalTextAlignment = TextAlignment.Center,\n                            FontAttributes = FontAttributes.Bold,\n                            FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),\n                            Text = Device.RuntimePlatform == Device.Android ? \"Welcome to Xamarin.Forms.Android!\" :\n                            Device.RuntimePlatform == Device.iOS ? \"Welcome to Xamarin.Forms.iOS!\" :\n                            Device.RuntimePlatform == Device.UWP ? \"Welcome to Xamarin.Forms.UWP!\" :\n                            \"Welcome to Xamarin.Forms.Tizen-\" + (Device.Idiom == TargetIdiom.Phone ? \"Mobile\" : \"TV\"),\n                        }\n                    }\n            };\n        }\n    }\n}\n<\/pre>\n<h2 id=\"runontizenemulators\" style=\"clear: both\">Run on Tizen Emulators<\/h2>\n<p>Let\u2019s run <em>SimpleText<\/em> on Tizen emulators. Start your emulators at <strong>Tools -&gt; Tizen -&gt; Tizen Emulator Manager<\/strong>. Three types of Tizen profiles are provided, with wearable now in the preview version. The text is displayed differently on the different devices.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-35711\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/TizenMobile.png\" alt=\"\" width=\"228\" height=\"400\" \/>\n&nbsp;\n<img decoding=\"async\" class=\"aligncenter wp-image-35710\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/TizenTV.png\" alt=\"\" width=\"700\" height=\"343\" \/>\n&nbsp;\n<img decoding=\"async\" class=\"aligncenter wp-image-35709\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/TizenWearable.png\" alt=\"\" width=\"294\" height=\"400\" \/><\/p>\n<h2 id=\"startnow\" style=\"clear: both\">Start Now<\/h2>\n<p>Tizen .NET is now ready for any developer who wants to create a fabulous app that works on various platforms and device types. For Xamarin.Forms developers, you now know enough to create a Tizen app.<\/p>\n<blockquote style=\"text-align: left;font-size: 12px;padding: 10px 20px;border-left: 3px solid #2c3e50\"><p>If you&#8217;re interested in learning more about developing Tizen TV apps, visit <a href=\"http:\/\/developer.samsung.com\/tv\/tizen-net-tv\/getting-started\/creating-net-tv-applications\">the getting started documentation here<\/a> to find more guides and see TV specific API references.<\/p><\/blockquote>\n<p><a href=\"https:\/\/forums.xamarin.com\/\">Discuss this post on the forums!<\/a>\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a special guest post from Jay Cho of the Samsung Tizen team. It&#8217;s been a while since the first preview version of Tizen .NET was released. Thanks to the newest release, developing Xamarin.Forms applications with Tizen projects has never been so easy. Using the familiar Visual Studio IDE, you can now develop applications [&hellip;]<\/p>\n","protected":false},"author":1936,"featured_media":35709,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[16],"class_list":["post-35706","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-xamarin-forms"],"acf":[],"blog_post_summary":"<p>This is a special guest post from Jay Cho of the Samsung Tizen team. It&#8217;s been a while since the first preview version of Tizen .NET was released. Thanks to the newest release, developing Xamarin.Forms applications with Tizen projects has never been so easy. Using the familiar Visual Studio IDE, you can now develop applications [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/35706","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\/1936"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=35706"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/35706\/revisions"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=35706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=35706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=35706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}