Я изучаю Xamarin, я хотел бы получить idex повернутого элемента в моем CarouselView
Вот код Xaml:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
x:Name="currentPage">
<StackLayout >
<CarouselView x:Name="TestList" >
<CarouselView.ItemTemplate >
<DataTemplate>
<StackLayout >
<StackLayout Grid.Row="3" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding CarouselItemTapped,Source={x:Reference currentPage}}" CommandParameter="{Binding .}"/>
</StackLayout.GestureRecognizers>
</StackLayout>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
</StackLayout>
Вот мой c# код :
Инициализация:
public ICommand CarouselItemTapped { get; set; } // initialize my command
new List<TestModel> ListWordsTest = new List<TestModel>(); // initialize my list of TestModel
// the Model I use get strings elements declared as Public {get; set;}
TestModel testmodel = new TestModel
{
Word1 = "word1", // type string
Word2 = "word2", //type string
};
Получить информацию об элементе Tapped
//When I tapped The carousel I get information like this
CarouselItemTapped = new Xamarin.Forms.Command((selectItem) => {
var mynews = selectItem //as IDoNotKnow I would like to get the item index
});