Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - A Brief Look at Menus in WPF
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

A Brief Look at Menus in WPF
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-09-22

    Table of Contents:
  • A Brief Look at Menus in WPF
  • More on MenuItem
  • Handling Input
  • Context Menus

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    A Brief Look at Menus in WPF - More on MenuItem


    (Page 2 of 4 )

    In some situations, more functionality is needed for menu items. In certain situations, some menu items may need to be disabled. For example, consider a context menu for a standard text box, containing Copy, Cut and Paste menu items. If no text is highlighted, then it doesn't make sense for the user to be able to copy or cut anything. So, it makes sense for those options to be disabled.

    Whether or not a menu item is enabled is determined by the value of IsEnabled. You can set IsEnabled to false in order to disable a menu item. For example, below, the Copy and Cut menu items would be disabled:


    <MenuItem Header="Copy" IsEnabled="False" />

    <MenuItem Header="Cut" IsEnabled="False" />

    <MenuItem Header="Paste" />


    Another useful bit of functionality is a check box of sorts on a menu item. Some menu items can be made to turn a feature on or off. If the feature is on, a check mark will be placed to the left of the menu item's text. If the feature is off, then the check mark will not appear.

    This functionality is easy to implement. It involves two properties: IsCheckable and IsChecked. The IsCheckable property determines whether or not the item can be checked, and the IsChecked property determines whether or not the item actually is checked. The default value for IsChecked is false, so creating a checkable menu item without setting IsChecked will result in an unchecked menu item.

    Below, we create a menu item that can be checked:


    <MenuItem Header="Syntax Highlighting" IsCheckable="True" />


    And here, we create a menu item that is checked by default:


    <MenuItem Header="Standard Mode" IsCheckable="True"

     IsChecked="True" />


    In order to make menus more accessible, it's a good idea to provide access keys for menu items. This will not only make keyboard-loving users happy, but it will allow people with various disabilities to use your application. The presence of an access key is indicated by an underlined letter in an item's label. The item can be "clicked" by pressing Alt and the underlined letter.

    Access keys are very easy to implement. The process is the same as with any other control. When specifying the MenuItem's Header, simply add an underscore before the desired access key character. For example, with a File menu, an access key might be set up like this:


    <MenuItem Header="_File">

    ...

    </MenuItem>


    Pressing the Alt key will show the F as being underlined, and then pressing the F key will activate the File menu.

    More Windows Scripting Articles
    More By Peyton McCullough


       · Hey, all,Menus are obviously a huge part of many applications. In this article,...
     

    WINDOWS SCRIPTING ARTICLES

    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...
    - Modifying XML Files in WSH
    - Reading XML Files in WSH
    - Visual Basic 2005 XML Programming Using XML ...
    - Creating an XML Document in WSH
    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT