3

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

JTIM
  • 2,774
  • 1
  • 34
  • 74

1 Answers1

4

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

jjchiw
  • 4,375
  • 1
  • 29
  • 30
  • It is, but there's an ugly clip effect when the item is hold and the context menu appears. How could that be fixed? – VasileF Sep 19 '13 at 15:58
  • That Was something of what I was looking for. I will try this, and mark your question answered if it works out. Else I will come with more Questions. @VasileMarianFălămaș What do you mean with Clip Effect? – JTIM Sep 20 '13 at 07:11
  • Let's say you want to make the context menu appear for an item. You hold that item, and the item disappears (clips away) and then reappears along with the context menu. This behaviour isn't present in the Windows Phone apps the OS comes with. – VasileF Sep 20 '13 at 08:06
  • I still do not understand the clips away, I'm using the context menu of the apps that comes in windows phone and comparing with this example [youtube video](http://www.youtube.com/watch?v=q3YtFVe5bnE) and I think it looks the same – jjchiw Sep 20 '13 at 08:19