I have this XAML
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TapGestureForUpdateCategories, Source={x:Reference MainPage}}" CommandParameter="false" />
</Label.GestureRecognizers>
and this code in my ViewModel
public Command TapGestureForUpdateCategories => new Command(val =>
{
App.DB.UpdateAllCategoryGroups(val);
App.DB.UpdateAllCategory(val);
});
I am trying to pass the parameter true or false from the XAML but in the command C# code there is a line under val saying "Cannot convert from object to bool". Can anyone help me with this?
Modify as below , we can define the type we want by x:type inside TapGestureRecognizer.CommandParameter
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TapGestureForUpdateCategories, Source={x:Reference MainPage}}">
<TapGestureRecognizer.CommandParameter>
<x:Boolean>True</x:Boolean>
</TapGestureRecognizer.CommandParameter>
</TapGestureRecognizer>
</Label.GestureRecognizers>
You can use this approach
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TapGestureForUpdateCategories, Source={x:Reference MainPage}}" CommandParameter="{x:Boolean False}" />
</Label.GestureRecognizers>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With