У меня есть TapGestureRecognizer в ListView с обработчиком событий Tapped.Я хотел бы перейти к коду за свойством из Span следующим образом:
XAML
<ListView ItemsSource="{Binding GetCases}" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Margin="20,0,20,0">
<Label Text="Case Reference:" FontSize="14" TextColor="Green"/>
<Label FontSize="12" TextColor="Blue" FontAttributes="Bold">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding Ref}" TextColor="Blue" TextDecorations="Underline">
<Span.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_OnTapped" NumberOfTapsRequired="1" />
</Span.GestureRecognizers>
</Span>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Мой обработчик событий (свойство Ref, это то, что я хочу получить из XAML)
private void TapGestureRecognizer_OnTapped(object sender, EventArgs e)
{
var tappedPost = sender as Cases; // Cases is my model with the Ref property
Navigation.PushAsync(new CaseViewModel(tappedPost.Ref));
}
Я хотел бы получить свойство Ref из Xaml, как показано выше.Команда не работает для меня, из-за ListView (я пробовал).У меня работал только Tapped handler, но, к сожалению, он не восстанавливает свойство.Кто-нибудь здесь, чтобы помочь мне?Спасибо.