block-quote On this pagechevron-down
copy Copy chevron-down
Blazor AI Migrator chevron-right DCP: Desktop Compatibility Library ContextMenuStrip This document shares key information to enable, modify and use a ContextMenu out off browser's options.
The ContextMenuStrip implementation in the BlazorDCP project provides a seamless bridge between Windows Forms ContextMenuStrip functionality and Blazor applications using Telerik UI components. This implementation maintains full compatibility with existing Windows Forms event handling patterns while providing modern web-based context menu experiences.
Architecture Components
Core Model Class (Gap.Blazor.ContextMenuStrip)
Location: src\Gap.Blazor\Controls\ContextMenuStrip.csarrow-up-right
Copy /// < summary >
/// ContextMenuStrip model implementation.
/// </ summary >
/// < mapfrom > System.Windows.Forms.ContextMenuStrip </ mapfrom >
public class ContextMenuStrip : ToolStripDropDownMenu
{
public ContextMenuStrip ( IContainer container ) { /* ... */ }
public ShowEventHandler ShowEventHandler { get ; set ; }
public void Show ( Control control , Point position ) { /* ... */ }
private void OnShow ( ShowEventArgs e ) { /* ... */ }
}
Windows Forms Compatibility: Inherits from ToolStripDropDownMenu maintaining API compatibility
Event-Driven Architecture: Uses ShowEventHandler for display coordination
Position-Aware Display: Supports precise positioning via Point coordinates
Cancellable Events: Implements Opening event with CancelEventArgs for conditional display
Blazor Component (WMContextMenuStrip)
Location: src\Gap.Blazor.Components\Components\ContextMenuStrip\WMContextMenuStrip.razor
Component Properties:
Model Integration: Directly binds to ContextMenuStrip model instance
Hierarchical Support: Handles nested menu items through SubItems field
Template-Based Rendering: Uses WMToolStripMenuItem for consistent item display
Event Bridging: Connects Telerik events to Windows Forms event handlers.
Event flow architecture
Browser Context Menu Prevention
Challenge: Browser's native right-click context menu interferes with custom implementation.
Solution: Selective event prevention using JavaScript:
Last updated 5 months ago