It’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 Visual Studio Tools for Tizen, 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.
Prerequisites: If you’re brand new to developing Tizen .NET applications, start by browsing the Tizen development guides and learn how to install the Tizen SDK, emulators, and tools.
If you already have your own cross-platform Xamarin apps, or if you’re about to create a new one, it’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’ll show you how it’s done.
Add a Tizen Project
On Visual Studio
As an example, below is a sample cross-platform app named SimpleText, which shows a simple line of text in the center. The text varies depending on the Platform and Idiom:
On an Android Emulator, you’ll see the text displayed as “Welcome to Xamarin.Forms.Android!”.
On an iOS Simulator, the text is replaced with, “Welcome to Xamarin.Forms.iOS!”.
To run on the Tizen platform in Visual Studio:
Go to File -> Add -> New Project.
Select the Tizen cross-platform template Visual C# -> Tizen -> Blank App (Xamarin.Forms)
Give your project the name SimpleText.Tizen.
To run the Tizen project Wizard:
Select “Common” as the Profile. For future projects, the available profiles are Mobile, TV, and Wearable.
Choose Select Project in Solution.
Select SimpleText as the reference. The ability to select an existing reference is included in version 1.2.0 of Visual Studio Tools for Tizen.
Add code LoadApplication(new SimpleText.App()) to the SimpleText.Tizen/SimpleText.Tizen.cs file
View and Check the Reference
View the results and see if the generated Tizen project refers to the correct reference as a dependency:
Instead of adding a stable version of Xamarin.Forms NuGet package, you should use the Nightly Build, or the Xamarin.Forms.Platform.Tizen package as a reference at this time. Version 220.127.116.11107 of Xamarin.Forms.Platform.Tizen works beautifully.
When the Tizen renderers are shipped with Xamarin.Forms in the future, you’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 Nightly Builds.
There’s another significant package called Tizen.NET 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 Tizen developer guide to see which Tizen APIs are provided.
he Xamarin.Forms.Device class may be familiar to most Xamarin developers, as it provides useful public properties such as RuntimePlatform and Idiom. Those properties provide the OS and device to run on. In the SimpleText app, platforms and target devices are separated on the code, as below. See how the C# code is implemented, as well:
<?xml version=”1.0″ encoding=”utf-8″ ?>
<Label VerticalOptions=”Center” HorizontalOptions=”Center” FontSize=”Large” FontAttributes=”Bold”>
<On Platform=”Android” Value=”Welcome to Xamarin.Forms.Android!” />
<On Platform=”iOS” Value=”Welcome to Xamarin.Forms.iOS!” />
<On Platform=”UWP” Value=”Welcome to Xamarin.Forms.UWP!” />
<OnIdiom.Phone>Welcome to Xamarin.Forms.Tizen-Mobile</OnIdiom.Phone>
<OnIdiom.TV>Welcome to Xamarin.Forms.Tizen-TV</OnIdiom.TV>
You can try using TargetIdiom.Unsupported to test the code here on the Tizen wearable emulator. The idiom for the wearable device isn’t yet defined in Xamarin.Forms, but we expect to add this in the near future.
class MainPageCS : ContentPage
Content = new StackLayout
VerticalOptions = LayoutOptions.Center,
HorizontalTextAlignment = TextAlignment.Center,
FontAttributes = FontAttributes.Bold,
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
Text = Device.RuntimePlatform == Device.Android ? “Welcome to Xamarin.Forms.Android!” :
Device.RuntimePlatform == Device.iOS ? “Welcome to Xamarin.Forms.iOS!” :
Device.RuntimePlatform == Device.UWP ? “Welcome to Xamarin.Forms.UWP!” :
“Welcome to Xamarin.Forms.Tizen-” + (Device.Idiom == TargetIdiom.Phone ? “Mobile” : “TV”),
Let’s run SimpleText on Tizen emulators. Start your emulators at Tools -> Tizen -> Tizen Emulator Manager. Three types of Tizen profiles are provided, with wearable now in the preview version. The text is displayed differently on the different devices.
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.
References and Sources : XamarinBlogs