I have a Page with a ViewModel as a BindingContext:
public Page()
{
InitializeComponent();
this.BindingContext = new ViewModel();
}
ViewModel has a command:
public class ViewModel : INotifyPropertyChanged
{
...
public ICommand SomeCommand { get; set; }
public ViewModel()
{
SomeCommand = new Command((object data) => {});
}
...
}
In my Page.xaml I use my custom View component which serves the only to be displayed and has an ability to be clicked:
<local:CircleView
Radius="20"
InnerText="Click me"
InnerTextSize="15"
TapCommand="{Binding SomeCommand}"
/>
In my CircleView.xaml.cs
...
public ICommand TapCommand { get; set; }
...
In my CircleView.xaml:
...
<TapGestureRecognizer
Command="{Binding Path=TapCommand, Source={x:Reference Name=CircleView}}"
CommandParameter="{Binding Path=InnerText, Source={x:Reference Name=CircleView}}"
/>
...
When I run a program I get an error "No property, bindable property, or event found for TapCommand, or mismatching...". How can I pass a command in XAML?