Xamarin Forms Listitem(打开)手势
问题描述:
我有一个带有标签和条目的列表视图。我想要一个手势或东西,当我长按标签时,它将显示一个带有标签名称的警告显示。到目前为止,我只有当你按下一次,需要相同,但当你长按。Xamarin Forms Listitem(打开)手势
我的默认列表视图
var listView = new ListView();
var productDataTemplate = new DataTemplate(() =>
{
var grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition
{
Height = new GridLength(2, GridUnitType.Star)
});
var typeLabel = new Label { FontAttributes = FontAttributes.Bold,
BackgroundColor = Color.White};
typeLabel.SetBinding(Label.TextProperty, "Type");
var entry = new Entry
{
TextColor = Color.Black,
BackgroundColor = Color.White
};
entry.SetBinding(Entry.TextProperty, "Quantity");
grid.Children.Add(typeLabel,0,0);
grid.Children.Add(entry,1,0);
grid.BackgroundColor = Color.Black;
return new ViewCell { View = grid };
});
listView.ItemTemplate = productDataTemplate;
listView.ItemsSource = products;
listView.ItemSelected += (sender, e) => {
DisplayAlert("item tapped", e.SelectedItem.ToString(), "ok");
};
wrapLayout.Children.Add(listView);
答
AFAIK Xamarin.forms的代码支持点击,捏&潘姿态。所以要长时间按下,您需要为每个支持的平台使用CustomRenderer,或者您可以使用XForms lab,默认情况下它支持大多数包含长按的手势。希望有所帮助!
太棒了!就一件事;我在你的问题中没有看到什么_you_试过。你有没有尝试任何事情来实现这一目标?如果是这样,什么?你哪里失败了? *不是一个将为您编写代码的服务。请阅读[这里](https://*.com/help/how-to-ask)如何提出正确的问题。 –