New to Telerik UI for WPF? Start a free 30-day trial
How to Attach Context Menu to Gantt Event Containers
Updated on Sep 15, 2025
Environment
| Product Version | 2019.2.510 |
| Product | RadGanttView for WPF |
Description
How to display a context menu for the event container elements of RadGanttView.
Solution
Define the context menu on the RadGanttView level and show it only when an EventContainer is clicked. To do this, handle the ContextMenuOpening event.
XAML
<telerik:RadGanttView ContextMenuOpening="RadGanttView_ContextMenuOpening">
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu>
<telerik:RadMenuItem Header="Click me!" Command="{Binding MyCommand}" />
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:RadGanttView>
XAML
private void RadGanttView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
var source = (FrameworkElement)e.OriginalSource;
var container = source.ParentOfType<EventContainer>();
if (container == null)
{
e.Handled = true;
}
}
Setting e.Handled = true will cancel the menu opening.