<rotator:SfRotator Grid.Row="0"
SelectedIndexChanged="Rotator_SelectedIndexChanged"
x:Name="rotator"
NavigationStripMode="Dots"
DotPlacement="None">
<rotator:SfRotator.ItemTemplate>
<DataTemplate>
<Grid >
<Image VerticalOptions="Center" Aspect="Fill" HorizontalOptions="Center" Source="{Binding Image}"/>
</Grid>
</DataTemplate>
</rotator:SfRotator.ItemTemplate>
</rotator:SfRotator>
<StackLayout Grid.Row="1" x:Name="rotatorThumb" Orientation="Horizontal" HorizontalOptions="Center">
</StackLayout> |
public partial class MainPage : ContentPage
{
public List<RotatorViewModel> RotatorItems { get; set; }
public MainPage()
{
InitializeComponent();
RotatorItems = new List<RotatorViewModel>()
{
new RotatorViewModel(){Image="image3.jpg"},
new RotatorViewModel(){Image="image2.jpg"},
new RotatorViewModel(){Image="image1.jpg"},
new RotatorViewModel(){Image="image4.jpg"},
};
rotator.ItemsSource = RotatorItems;
for (var i = 0; i < RotatorItems.Count; i++)
{
var itemView = new DotsView() { BindingContext = RotatorItems[i], Index = i };
if (rotator.SelectedIndex == i)
(itemView.BindingContext as RotatorViewModel).ThumbBorder = Color.Red;
rotatorThumb.Children.Add(itemView);
}
BindingContext = this;
}
private void Rotator_SelectedIndexChanged(object sender, Syncfusion.SfRotator.XForms.SelectedIndexChangedEventArgs e)
{
foreach (DotsView thumbView in rotatorThumb.Children)
{
(thumbView.BindingContext as RotatorViewModel).ThumbBorder = Color.LightGray;
}
((rotatorThumb.Children[(int)e.Index] as DotsView).BindingContext as RotatorViewModel).
ThumbBorder = Color.Red;
}
} |
<ContentView.Content>
<border:SfBorder BorderColor="{Binding ThumbBorder}" HorizontalOptions="Center" VerticalOptions="Center" BorderWidth="5" CornerRadius="50" />
</ContentView.Content>
|
Syncfusion.XForms.iOS.Border.
SfBorderRenderer.Init()