在我的项目中,我使用了XamEffects包引用在这里输入链接描述
<StackLayout effect:Commands.Tap="{Binding OnTapped}" Grid.Row="1" Grid.ColumnSpan="3" Orientation="Horizontal" effect:TouchEffect.Color="Gray" effect:EffectsConfig.ChildrenInputTransparent="True">
<Image Source="ic_cont_downtick.png" HeightRequest="25" WidthRequest="25"/>
<StackLayout Orientation="Vertical" WidthRequest="250" Spacing="0" Margin="10,0,0,0" VerticalOptions="Center">
<Label Text="Downloaded Content" VerticalOptions="Center" TextColor="Black"/>
<Label BackgroundColor="#455EEC" HorizontalOptions="Start" VerticalOptions="Start" WidthRequest="20" HeightRequest="4"/>
</StackLayout>
<Image Source="ic_rightarrow_1.png" HeightRequest="10" WidthRequest="10" VerticalOptions="Center" HorizontalOptions="End"/>
</StackLayout>单击stackLayout时,必须导航另一个页面。但是TapGestureRecognizer不能处理这个包。只有指挥部才能起作用。
所以请帮帮我。问候
发布于 2018-07-05 09:36:21
下面是ViewModel类中绑定的代码
private Command onTapped;
private const string OnTappedCommandPropertyName = "OnTapped";
public Command OnTapped
{
get
{
return onTapped ?? (onTapped = new Command(ExecuteOnTappedCommand));
}
}
public void ExecuteOnTappedCommand()
{
//your code here
}希望能帮上忙!
发布于 2018-07-05 08:13:19
我认为不需要使用xamarin表单中的任何包来做到这一点,您所需要做的就是
<StackLayout>
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding tryit}"/>
</StackLayout.GestureRecognizers>
<Label Text="hello touch me"/>
</StackLayout>发布于 2018-08-27 21:46:03
我在自述中指定,您不能使用具有我的效果的手势:
重要:如果您需要一些具有触摸效果的手势,请不要使用GestureRecognizer,而是使用命令,因为Xamarin.Forms中的标准手势不能正常工作。
请在您的控件中使用命令:
effect:TouchEffect.Color="Gray"
effect:Commands.Tap="{Binding TapCommand}"
effect:EffectsConfig.ChildrenInputTransparent="True"在ViewModel中创建ICommand:
private ICommand _tapCommand;
public ICommand TapCommand => _tapCommand ?? (_tapCommand = new Command(TapExecute));
private void TapExecute()
{
//something
}https://stackoverflow.com/questions/51185836
复制相似问题