Hi,
I need to bind an event to a ListView's ItemSelected EventHandler .
The ListView is defined in a XAML file, it has a ViewModel class assigned and has a binding to the properties of the ViewModel, but when it comes to binding the Behaviour of the ItemSelected I have no idea on how to do that.
¿How could I do it?
Thanks
public partial class MainView:ContentPage
{
public MainView()
{
InitializeComponent();
BindingContext = new MainViewModel(this);
}
}
<ContentPage.Content>
<Grid>
<ListView ItemsSource="{Binding Events}" x:Name="ListViewEvents">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Padding="5, 5, 0, 5"
Orientation="Vertical">
<Label Text="{Binding Title }" Font = "{x:Static fonts:Fonts.TitleFont}" />
<Label Text="{Binding Location}" Font = "{x:Static fonts:Fonts.LabelFont}"/>
<Label Text="{Binding Description}"/>
<Label Text="{Binding PeopleGoing, StringFormat='{0:F0} people are going'}"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</ContentPage.Content>