Xamarin Community Toolkit ItemSelectedEventArgsConverter
Das ItemSelectedEventArgsConverter ist ein Konverter, mit dem Benutzer den SelectedItem
Wert aus einem SelectedItemChangedEventArgs-Objekt extrahieren können. Anschließend kann sie in Kombination mit EventToCommandBehavior
.
Syntax
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:Class="MyLittleApp.MainPage">
<ContentPage.Resources>
<ResourceDictionary>
<xct:ItemSelectedEventArgsConverter x:Key="ItemSelectedEventArgsConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<ListView ItemsSource="{Binding Items}" HasUnevenRows="True">
<ListView.Behaviors>
<xct:EventToCommandBehavior EventName="ItemSelected"
Command="{Binding ItemSelectedCommand}"
EventArgsConverter="{StaticResource ItemSelectedEventArgsConverter}" />
</ListView.Behaviors>
</ListView>
</ContentPage>
Beispiel
ElementSelectedEventArgsConverter-Beispielseite Source
Sie können dies in Aktion in der Xamarin Community Toolkit-Beispiel-App sehen.