I can't seem to get the Command interface to work with an ImageCell in XAML.
The rest of the data that I'm binding the view with is working just fine, with the exception of the Command property, which is not getting called.
I know I must missing something or perhaps my syntax is wrong.
Here's a portion of my XAML file....
<ListView x:Name="MenuItemsList"
ItemsSource="{Binding Data}">
<ListView.ItemTemplate>
<DataTemplate>
<ImageCell Text="{Binding Title}"
TextColor="Black"
ImageSource="{Binding IconSource}">
<ImageCell.GestureRecognizer>
<TapGestureRecognizer Command="{Binding MenuItemPressed}">
</TapGestureRecognizer>
</ImageCell.GestureRecognizer>
</ImageCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I also tried adding the Command attribute directly in the ImageCell like so...
<ListView x:Name="MenuItemsList"
ItemsSource="{Binding Data}">
<ListView.ItemTemplate>
<DataTemplate>
<ImageCell Text="{Binding Title}"
TextColor="Black"
ImageSource="{Binding IconSource}"
Command="{Binding MenuItemPressed}">
</ImageCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
And here's my view model...
class MainMenuViewModel: ViewModelBase
{
public List<MainMenuItem> Data { get; set; }
public MainMenuViewModel()
{
Data = new MenuListData();
MenuItemPressed = new Command(NavigateToPage);
}
void NavigateToPage()
{
System.Diagnostics.Debug.WriteLine("executing the navigatetopage command");
}
public ICommand MenuItemPressed { private set; get; }
}
Thanks.