1
我是MVVM的新手,并且在我的Xamarin.Forms应用中出现了一些问题。Xamarin ICommand没有解雇
下面是我在SessionsPage.xml
<Grid.Children>
<Image Source="zero.jpg" Grid.Row="0" Grid.Column="0">
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding TapCommand}"
CommandParameter="0" />
</Image.GestureRecognizers>
我有一个链接到命令“TapCommand”的图像。
在该视图的构造函数中,我说:
而且ViewModel类是:
public class TapViewModel : INotifyPropertyChanged
{
int taps = 0;
ICommand tapCommand;
public event PropertyChangedEventHandler PropertyChanged;
public TapViewModel()
{
// configure the TapCommand with a method
tapCommand = new Command(OnTapped);
}
public ICommand TapCommand
{
get { return tapCommand; }
}
void OnTapped(object s)
{
taps++;
Debug.WriteLine("parameter: " + s);
}
//region INotifyPropertyChanged code omitted
}
,而该事件不触发,有什么不好?