Hold Event Longlistselector

我是研究僧i 提交于 2019-12-01 22:26:38

问题


Hej

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?

Extra

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;
    }

And

    <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>

A good link for easy implementation is also youtube link below, replicated here : Youtube


回答1:


A ContextMenu is one option..

http://blogs.msdn.com/b/msgulfcommunity/archive/2013/05/19/windows-phone-toolkit-context-menu-getting-selected-item-within-a-long-list-selector.aspx



来源:https://stackoverflow.com/questions/18897492/hold-event-longlistselector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!