Skip to content

Instantly share code, notes, and snippets.

@myroot
Created September 21, 2020 01:48
Show Gist options
  • Save myroot/e5e9f88f46ade609ef51fecf917b322c to your computer and use it in GitHub Desktop.
Save myroot/e5e9f88f46ade609ef51fecf917b322c to your computer and use it in GitHub Desktop.
CarouselView + Indicator Sample on Tizen
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CarouselViewSample"
x:Class="CarouselViewSample.App">
<Application.Resources>
</Application.Resources>
<Application.MainPage>
<local:MainPage/>
</Application.MainPage>
</Application>
<Project Sdk="Tizen.NET.Sdk/1.0.9">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>tizen40</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Tizen.Wearable.CircularUI" Version="1.5.1" />
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1451" />
</ItemGroup>
</Project>
using Xamarin.Forms;
using Tizen.Wearable.CircularUI.Forms;
namespace CarouselViewSample
{
class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
{
protected override void OnCreate()
{
base.OnCreate();
LoadApplication(new App());
}
static void Main(string[] args)
{
var app = new Program();
Forms.SetFlags("IndicatorView_Experimental");
Forms.Init(app);
FormsCircularUI.Init();
app.Run(args);
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CarouselViewSample.MainPage">
<Grid>
<CarouselView x:Name="carouselView" IndicatorView="{x:Reference indicatorView}">
<CarouselView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>1</x:String>
<x:String>2</x:String>
<x:String>3</x:String>
<x:String>4</x:String>
<x:String>5</x:String>
</x:Array>
</CarouselView.ItemsSource>
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="BlueViolet" Margin="10">
<Label FontSize="30" Text="{Binding .}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
<IndicatorView x:Name="indicatorView"
IndicatorColor="LightGray"
SelectedIndicatorColor="DarkGray"
HorizontalOptions="FillAndExpand"/>
</Grid>
</ContentPage>
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace CarouselViewSample
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
carouselView.Focus();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment