Reputation: 137
I need EventToCommandBehavior for DataGridView.
<pages:PopupPage.Resources>
<ResourceDictionary>
<xct:ItemTappedEventArgsConverter x:Key="ItemTappedEventArgsConverter"/>
</ResourceDictionary>
</pages:PopupPage.Resources>
<ListView ItemsSource="{Binding Liste}">
<ListView.Behaviors>
<xct:EventToCommandBehavior
EventName="ItemTapped"
Command="{Binding ListeTapCommand}"
EventArgsConverter="{StaticResource ItemTappedEventArgsConverter}"
/>
</ListView.Behaviors>
</ListView>
I can use EventToCommandBehavior for a normal listview but when i try to use for DataGridView i couldn't find any EventArgsConverter for Datagridview. How can i handle this issue ?
Thanks for Jason i could write my own converter.
Solution : You need a new class for event args :
public class DataGridGestureEventArgsConverter : BaseNullableConverterOneWay<DataGridGestureEventArgs, object>
{
/// <summary>
/// Converts/Extracts the incoming value from <see cref="DataGridGestureEventArgs"/> object and returns the value of <see cref="DataGridGestureEventArgs.Item"/> property from it.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>A <see cref="DataGridGestureEventArgs.Item"/> object from object of type <see cref="DataGridGestureEventArgs"/>.</returns>
public override object ConvertFrom(DataGridGestureEventArgs value) => value?.Item;
}
xmlns:data="clr-namespace:YourApp.Data"
<pages:PopupPage.Resources>
<ResourceDictionary>
<xct:ItemTappedEventArgsConverter x:Key="ItemTappedEventArgsConverter"/>
<data:DataGridGestureEventArgsConverter x:Key="DataGridGestureEventArgsConverter"/>
</ResourceDictionary>
</pages:PopupPage.Resources>
<dxg:DataGridView.Behaviors>
<xct:EventToCommandBehavior
EventName="Tap"
Command="{Binding ListeTapCommand}"
EventArgsConverter="{StaticResource DataGridGestureEventArgsConverter}"/>
</dxg:DataGridView.Behaviors>
It works well like this.
Upvotes: 0
Views: 67