Reputation: 1476
Is it possible to create some kind of info menu when a button has triggered the event Hold. I've looked a bit into the ContextMenu, but this does not close automatically when the you stop holding. What I want is a PopUp, or a similar thing which shows some kind of info when the button event Hold is pressed, and closes when it is no more "Holded". Is this possible and in that case what should I use?
Upvotes: 4
Views: 578
Reputation: 9434
Yes you could use the Popup Class to display any kind of message or whatever the option you want.
Refer some of these samples:
For the hold event you could use the toolkit:
XAML:
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Hold="GroupItem_Hold"/>
</toolkit:GestureService.GestureListener>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="Remove Group" Click="removeGroup"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
.cs:
private void removeGroup(object sender, RoutedEventArgs e)
{
//do something here
}
private void GroupItem_Hold(object sender, GestureEventArgs e)
{
var holdItem = (sender as StackPanel).DataContext as Usergroup;
App.selectedGroup = holdItem.id.ToString();
grp_name = holdItem.groupName;
}
I used the above code to get the details of an item from a listbox when a user holds on that particular item.
Hope it helps :)
Upvotes: 0
Reputation: 2771
I would guess a solution could be to use popup as you say. So when the hold event is fired you show a popup by using the position of your finger. When the user releases the screen the manipulation ended event should be fired, then you can use a boolean to check if it was a hold event or not.
If it was a hold event then you close the popup, or delete it, if you need to remove it from memory.
Upvotes: 1