Bind Commands.Tap from inside bound list in xaml
mrdnote opened this issue · 2 comments
Any idea why this isn't working? I'm trying to setup binding from xaml like this:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Name="Detail"
<!-- irrelevant code snipped -->
<local:BindableStackLayout
<!-- irrelevant code snipped -->
<StackLayout
xe:TouchEffect.Color="{StaticResource NavigationPrimary}"
xe:Commands.Tap="{Binding PromotionTapCommand, Source={x:Reference Detail}}"
xe:Commands.TapParameter="{Binding Id}">
In code behind:
public ICommand PromotionTapCommand { get; set; } = new Command<string>(PromotionTapped);
private static void PromotionTapped(string value)
{
throw new NotImplementedException();
}
But the event is not fired. If I use this principle it works:
Commands.SetTap(itemTemplate, new Command(() =>
{
throw new NotImplementedException();
}));
But this involves a lot of event forwarding. I prefer if I could specify the commands in xaml.
Also when I put the binding on a view directly in the page it works. So there must be something with bounded lists and your component thats not playing well together.
Thanks!
Could you make a example app with all your example?
I don't see whole point. Maybe you need set in command handle method getting object instead string. Or something else. I think in some step you did something wrong, I just today using this lib in my projects, including in bounded lists.
Looks like you were right. My parameter was an int, but I declared it as string in the command.. Seems that the framework doesn't match it to the command in that case.
Thanks for the help!!