Menu item action handler : Menu « Windows Presentation Foundation « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Windows Presentation Foundation » MenuScreenshots 
Menu item action handler
Menu item action handler
     
<Window x:Class="WpfApplication1.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="FlowDocReader Load/Save Sample" Width="640" Height="480">
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="22"/>
      <RowDefinition/>
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
      <ColumnDefinition/>
    </Grid.ColumnDefinitions>

    <Menu Grid.Row="0">
      <MenuItem>
        <MenuItem.Header>File</MenuItem.Header>
        <MenuItem Click="LoadFile">
          <MenuItem.Header>Load</MenuItem.Header>
        </MenuItem>
        <MenuItem Click="SaveFile">
          <MenuItem.Header>Save As...</MenuItem.Header>
        </MenuItem>
        <MenuItem Click="Clear">
          <MenuItem.Header>Clear Content</MenuItem.Header>
        </MenuItem>
        <MenuItem Click="Exit">
          <MenuItem.Header>Exit</MenuItem.Header>
        </MenuItem>
      </MenuItem>
    </Menu>
    
    <FlowDocumentReader Name="FlowDocRdr" Grid.Row="1"/>
    
  </Grid>
</Window>

//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Shapes
Imports System.Windows.Forms
Imports System.IO
Imports System.Windows.Markup

Namespace WpfApplication1

  Public Partial Class Window1
    Inherits Window

    Public Sub New()
      InitializeComponent()
    End Sub

    Private Sub LoadFile(sender As [Object], args As RoutedEventArgs)
      Console.WriteLine("load")
    End Sub

    Private Sub SaveFile(sender As [Object], args As RoutedEventArgs)
      Console.WriteLine("save")
    End Sub

    Private Sub Clear(sender As [Object], args As RoutedEventArgs)
      FlowDocRdr.Document = Nothing
    End Sub
    Private Sub [Exit](sender As [Object], args As RoutedEventArgs)
      Me.Close()
    End Sub
  End Class
End Namespace

   
    
    
    
    
  
Related examples in the same category
1.Mixed MenusMixed Menus
2.Sidebar MenuSidebar Menu
3.Put a Menu and toolbar on the top of a DockPanelPut a Menu and toolbar on the top of a DockPanel
4.Nesting content inside MenuItem.HeaderNesting content inside MenuItem.Header
5.Multiple command targetsMultiple command targets
6.Commands with a menu and text boxCommands with a menu and text box
7.Set Access key for Menu with underscoreSet Access key for Menu with underscore
8.Menu and MenuItemMenu and MenuItem
9.MenuItem Commands And EventsMenuItem Commands And Events
10.Display a Context Menu with OpacityDisplay a Context Menu with Opacity
11.MenuBar and ToolBarMenuBar and ToolBar
12.Add Menu to NavigationWindow ContentAdd Menu to NavigationWindow Content
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.