IT tutorials
 
Mobile
 

Windows Phone 8 : Windows Phone Toolkit (part 2) - ContextMenu Control, DatePicker and TimePicker Controls

6/23/2013 7:48:50 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

2. ContextMenu Control

The purpose of the ContextMenu control is to allow users to long-click on parts of your application to get a list of options. The control by default shows itself large enough to be obvious to the user. You can see the ContextMenu control in action with three menu items and a separator in Figure 3.

Image

FIGURE 3 ContextMenu example

The structure of the ContextMenu control consists of a ContextMenu element with a collection of one or more items inside the ContextMenu. There is only a single level of menu items, so no submenus are supported. The two types of items are MenuItem elements and Separator elements:

<toolkit:ContextMenu>
  <toolkit:MenuItem Header="Add" />
  <toolkit:MenuItem Header="Remove" />
  <toolkit:Separator />
  <toolkit:MenuItem Header="Cancel" />
</toolkit:ContextMenu>

To add a context menu to a XAML element, you use the ContextMenu attached property to apply it to your design, like so:

<Grid>
  <toolkit:ContextMenuService.ContextMenu>
    <toolkit:ContextMenu>
      <toolkit:MenuItem Header="Add" />
      <toolkit:MenuItem Header="Remove" />
      <toolkit:Separator />
      <toolkit:MenuItem Header="Cancel" />
    </toolkit:ContextMenu>
  </toolkit:ContextMenuService.ContextMenu>
  ...
</Grid>

After the menu is attached to the element, a user touch-hold will cause the menu to be displayed. The individual MenuItem elements can launch code either via an event or via a Command binding:

...

<toolkit:MenuItem Header="Add"
                  Click="MenuItem_Click" />
<toolkit:MenuItem Header="Remove"
                  Command="{Binding RemoveCommand}" />
...


Should You Use a ContextMenu?

Although the ContextMenu is a powerful control and useful in many situations, you should avoid the use of this control. The reason is that a context menu isn’t very discoverable by the user. Adding functionality via the ContextMenu means only a small number of your users might find the functionality. A common approach is to use the ContextMenu for quick access to features that are available in other parts of the application so that power users might use it but features aren’t hidden from normal users.


3. DatePicker and TimePicker Controls

If you’ve designed desktop or web applications before, you probably are used to finding a calendar control to allow users to pick dates. The problem with a calendar control on the phone is that the interface is not very touch-friendly. Instead, the phone supports a control for choosing dates: DatePicker. Using the DatePicker is as simple as using the XAML element:

...
<TextBlock>Pick Date</TextBlock>
<toolkit:DatePicker />
...

The DatePicker looks like a simple TextBox that accepts a date. The difference is that when a user taps the control, it launches a full-screen date-picking user interface, as shown in Figure 4.

Image

FIGURE 4 Date-picking user interface

The date-picking user interface allows the user to pan and flick to pick the date. This interface works really well with a touch interface. The DatePicker control defaults to DateTime.Now, which is why the current date is shown. You can specify a date using the Value property:

<toolkit:DatePicker Value="04/24/1969" />

The TimePicker works in exactly the same way as the DatePicker but uses the time portion of the DateTime structure:

...
<TextBlock>Pick Time</TextBlock>
<toolkit:TimePicker Value="12:34 PM" />
...

The user interface for picking the time is similar to the DatePicker, but it enables you to specify the time instead, as shown in Figure 5.

Image

FIGURE 5 Time-picking user interface

 
Others
 
- Windows Phone 8 : Windows Phone Toolkit (part 1) - AutoCompleteBox Control
- Android 3 : Employing Basic Widgets - Turn the Radio Up, It's Quite a View
- Android 3 : Employing Basic Widgets - Just Another Box to Check
- iTunes on Your iPad : Purchasing or Renting Music, Videos, Podcasts, and More
- iTunes on Your iPad : iTunes U – Great Educational Content, Searching iTunes
- iTunes on Your iPad : Finding Music with Featured, Top Charts, and Genius
- BlackBerry Java Application Development - Changing the perspective
- BlackBerry Java Application Development - Starting the debugger
- BlackBerry Java Application Development - Running an application in the simulator
- Windows Phone 7 : Silverlight User Interface Development - Designing for Windows Phone 7 (part 2) - Designer and Developer Mechanics
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us