问题描述
嘿嘿
我想创建一个标准的holdevent.当你按住一个元素时,会出现一些你可以选择的选项,比如一个新列表.
I want to create a standard holdevent. When you hold an element, there would appear some options you could chose like a new list.
你是如何创建这个的,是简单地通过弹出窗口完成还是有更聪明的方法?
How do you create this, is it just simply done with a popup or is there a smarter way?
额外
找到答案后,请看下面的答案,一些不错的信息是:
After finding the answer, see answer below, some nice info is:
将上下文创建放在保持事件中.然后您可以根据项目更改为不同的上下文菜单.您可以获取以下持有的项目
Put the context creation inside the hold event.Then you can change to different contextmenus depending on the item. You can get the item that was holded by the following
private void StackPanel_Hold(object sender, GestureEventArgs e)
{
ItemViewModel itemViewModel = (sender as StackPanel).DataContext as ItemViewModel;
string t = itemViewModel.LineOne;
}
和
<ListBox x:Name="MainListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Height="78" Hold="StackPanel_Hold">
<TextBlock Text="{Binding LineOne}" />
<TextBlock Text="{Binding LineTwo}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
一个易于实施的好链接也是下面的youtube链接,复制在这里:Youtube
A good link for easy implementation is also youtube link below, replicated here :Youtube
推荐答案
ContextMenu 是一种选择..
A ContextMenu is one option..
这篇关于保持事件长列表选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!