Hello,
images loop=true
it starts from 0 index expected 1 again
As described in the Doc : Position
, of type int
, the index of the current item in the underlying collection, the first item's index is 0. You can get the correct index value by using % to do the remainder calculation, so you should plus one when displaying the position.
currentCounter.Text = (mainCarousel.Position+1).ToString();
when I swipe images manually how to show current item on currentCounter as same as ( for example 3 images 3/1 3/2 3/3 - 3/1 like that go on )
You could call PositionChanged
event to response to the position changing.
<CarouselView x:Name="mainCarousel"...
PositionChanged="mainCarousel_PositionChanged"
>
private void mainCarousel_PositionChanged(object sender, PositionChangedEventArgs e)
{
int currentItemPosition = e.CurrentPosition;
currentCounter.Text = (currentItemPosition + 1).ToString();
}
In addition, you could try to move the adding timer method into Loaded
method instead of constructor method, and set currentCounter.Text
to the default value of 1.
public Carousel()
{
InitializeComponent();
this.Loaded += Carousel_Loaded;
}
private void Carousel_Loaded(object sender, EventArgs e)
{
totalCounter.Text = ItemsSource.Count.ToString();
currentCounter.Text = (mainCarousel.Position + 1).ToString();// default 1
...
timer.Start();
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.