Gets or sets the main automation context menu.
Syntax
Visual Basic (Declaration) | |
---|
Public Property ContextMenu As ContextMenu |
XAML Property Element Usage | |
---|
<object>
<object.ContextMenu>
<ContextMenu .../>
</object.ContextMenu>
</object> |
XAML Property Element Usage | |
---|
<object>
<object.ContextMenu>
<ContextMenu .../>
</object.ContextMenu>
</object> |
Return Value
The main automation context menu
Example
This example adds a "Test" menu item to the main automation context menu.
Visual Basic | Copy Code |
---|
Private Sub AnnAutomationManager_ContextMenu(ByVal manager As AnnAutomationManager)
Dim cm As ContextMenu = manager.ContextMenu
cm.Items.Add(New Separator())
Dim mi As MenuItem = New MenuItem()
mi.Header = "Test"
AddHandler mi.Click, AddressOf MyTestMenuItemHandler
cm.Items.Add(mi)
End Sub
Private Sub MyTestMenuItemHandler(ByVal sender As Object, ByVal e As RoutedEventArgs)
MessageBox.Show("Test clicked")
End Sub |
C# | Copy Code |
---|
private void AnnAutomationManager_ContextMenu(AnnAutomationManager manager) { ContextMenu cm = manager.ContextMenu; // add a separator cm.Items.Add(new Separator()); // add a test menu item MenuItem mi = new MenuItem(); mi.Header = "Test"; mi.Click += new RoutedEventHandler(MyTestMenuItemHandler); cm.Items.Add(mi); } private void MyTestMenuItemHandler(object sender, RoutedEventArgs e) { MessageBox.Show("Test clicked"); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family
See Also