Tizen Wearable XAML App Template
Following are the steps to create a Tizen Wearable XAML App Template:
Create Project
-
In New project menu, select Tizen > Tizen Wearable XAML App. Click OK.
-
Search Xamarin.Forms NuGet package and install the latest version (supports version 3.1.0.583944 and higher) via NuGet package manager. Package source is Nuget.org.
-
Search Tizen.Wearable.CircularUI NuGet package and install latest version via NuGet package manager. Package source is Nuget.org.
Insert CircularUI Control Code
-
In App.xaml file, remove all of the template code and replace it with the following code. This code defines the user interface for the page:
App.xaml file
XMLCopy<?xml version="1.0" encoding="utf-8" ?> <Application x:Class="SampleCircleApp.App" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:SimpleCircleApp" xmlns:w="clr-namespace:Tizen.Wearable.CircularUI.Forms;assembly=Tizen.Wearable.CircularUI.Forms"> <Application.MainPage> <NavigationPage x:Name="MainNavigation"> <x:Arguments> <w:CirclePage x:Name="page" NavigationPage.HasNavigationBar="False" RotaryFocusObject="{x:Reference slider}"> <w:CirclePage.Content> <StackLayout HorizontalOptions="Center" Orientation="Vertical" VerticalOptions="Center"> <Label HorizontalTextAlignment="Center" Text="Welcome to Xamarin Forms!" /> <Button Clicked="OnButtonClicked" Text="show toast" /> </StackLayout> </w:CirclePage.Content> <w:CirclePage.CircleSurfaceItems> <w:CircleSliderSurfaceItem x:Name="slider" Increment="0.5" IsVisible="True" Maximum="15" Minimum="0" Value="3" /> </w:CirclePage.CircleSurfaceItems> </w:CirclePage> </x:Arguments> </NavigationPage> </Application.MainPage> </Application>
xmlns:w=clr-namespace:Tizen.Wearable.CircularUI.Forms
:w
prefix meansTizen.Wearable.CircularUI.Forms
namespace.<w:CirclePage>
:CirclePage
is derived fromXamarin.Forms.Page
. This page content area hasLabel
andButton
.<w:CirclePage.CircleSurfaceItems>
:CircleSliderSurfaceItem
is attached toCircleSurfaceItem
ofCirclePage
.RotaryFocusObject
is set reference of theslider
.CircleSliderSurfaceItem
has rotary focus.CircleSliderSurfaceItem
can receive a Rotary Event from the wearable device’s bezel interaction.
For more information, see CirclePage guide.
-
In App.xaml.cs, remove all of the template code and replace it with the following code:
App.xaml.cs file
C#Copyusing Tizen.Wearable.CircularUI.Forms; using System; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace SampleCircleApp { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class App : Application { public App() { InitializeComponent(); } public void OnButtonClicked(object sender, EventArgs e) { Toast.DisplayText("Toast popup", 3000); } } }
- This code displays Toast popup during three seconds.
OnButtonClicked
is an event handler ofButton
Clicked
event.
Build and Launch Your Application
-
Build the solution
- In the Visual Studio menu, select Build > Build Solution.
- In the Solution Explorer view, right-click the solution name and select Build.
-
Launch Tizen Emulator
-
Click Launch Tizen Emulator button, as displayed in the following image:
-
Select your device type and click Launch button, as displayed in the following image:
-
-
Copy the application
For Windows OS, copy the application tpk file from the project binary path to sdb tool path.
SampleCircleApp
tpk file is located inProjectPath\SampleCircleApp\SampleCircleApp\bin\Debug\tizen40\org.tizen.example.SampleCircleApp-1.0.0.tpk
.- To locate the project path, in the Solution Explorer view, right-click the solution name and click open folder in file explorer.
- SDB tool is located in
c:\tizen\tools\sdb.exe
.
-
Launch Tizen SDB command prompt
- For Windows OS, launch Tizen SDB command prompt (Tool > Tizen > Tizen Sdb Command Prompt).
- For Linux, you can use SDB command directly in your project path.
-
Install your application with SDB command
bashCopysdb install org.tizen.example.SampleCircleApp-1.0.0.tpk
-
Launch wearable emulator to verify the application
Related Information
- Dependencies
- Tizen 4.0 and Higher