This is a migrated thread and some comments may be shown as answers.

Display a context menu after timeout

1 Answer 36 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Ciaran
Top achievements
Rank 1
Ciaran asked on 10 Sep 2009, 12:32 PM
I'd like to create a "LongClick" type behavior where a context menu displays after a short delay... is that possible with the RadContextMenu? I don't see a listing of the strings of the EventNames that you can use to display the menu in the documentation anywhere.

I thought I could set or bind the IsOpen property of the menu... My idea was that I'd bind it to a property that would change after the delay elapsed. But setting the property to "True" causes a crash AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 37 Position: 54]


<
Button Content="Menu" Visibility="{Binding MenuButtonVisibility}">

 

 

 

<telerikNavigation:RadContextMenu.ContextMenu>

 

 

 

<telerikNavigation:RadContextMenu IsOpen="True" >

 

 

 

<telerikNavigation:RadMenuItem Header="Edit..." />

 

 

 

<telerikNavigation:RadMenuItem Header="Add..." />

 

 

 

<telerikNavigation:RadMenuItem IsSeparator="True"/>

 

 

 

<telerikNavigation:RadMenuItem Header="Cut" />

 

 

 

<telerikNavigation:RadMenuItem Header="Paste" />

 

 

 

<telerikNavigation:RadMenuItem IsSeparator="True"/>

 

 

 

<telerikNavigation:RadMenuItem Header="Delete"

 

 

cal:Click.Command="{Binding DeleteItemCommand}"

 

 

cal:Click.CommandParameter="{Binding Location}"/>

 

 

 

</telerikNavigation:RadContextMenu>

 

 

 

</telerikNavigation:RadContextMenu.ContextMenu>

 

 

 

</Button>

 


and binding it to a value in my ViewModel does nothing at all.

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 16 Sep 2009, 03:49 PM
Hello Ciaran,

RadContextMenu does not support setting IsOpen in XAML, hence the AG_E_PARSER_BAD_PROPERTY_VALUE exception. You should set it in an event handler, that is executed after Loaded, for example Button.Click. There is no list with the supported events for RadContextMenu because it will try to attach to any CLR event with the provided name if such is present. The only exception is the right-click event which is non-standard routed event, implemented by us.

Please, find attached a simple example that demonstrates how to open a context menu if the mouse button was hold more than 500ms. I didn't manage to make it entirely in the view model, but I suppose the idea is clear. Let me know if you need additional information.

All the best,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Menu
Asked by
Ciaran
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or