יום שני, 10 ביוני 2013

A simple surface menu

Note the the opening of the menu is depended in clicking the label

  1: <Window x:Class="myLearn.MainWindow"
  2:         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3:         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4:           xmlns:s="http://schemas.microsoft.com/surface/2008"
  5:         Title="MainWindow" Height="350" Width="525">
  6:     <Grid>
  7:             <Grid.RowDefinitions>
  8:                 <RowDefinition Height="50"/>
  9:                 <RowDefinition Height="*"/>
 10:             </Grid.RowDefinitions>
 11: 
 12:             <Grid Name="MenuGrid" Grid.Row ="1" Visibility="Visible">
 13: 
 14:             <Label Name="OpenMenuLabel"
 15:                 Content="Touch here to open managment menu" 
 16:                 HorizontalAlignment="Center" VerticalAlignment="Center"/>
 17: 
 18: 
 19:             <s:ElementMenu 
 20:                 Name="MainMenu"
 21:                 ActivationMode="HostInteraction" 
 22:                 ActivationHost="{Binding ElementName=MenuGrid}">
 23:                     <s:ElementMenuItem Header="Handle Tasks"/>
 24:                   
 25:                     <s:ElementMenuItem Header="Handle HR">
 26:                         <s:ElementMenuItem Header="Show Operator" Command="{Binding Path=ShowOperatorCmd}"/>
 27:                         <s:ElementMenuItem Header="Show Mgrs"/>                  
 28:                     </s:ElementMenuItem>
 29:                 </s:ElementMenu>
 30:         </Grid>
 31:     </Grid>
 32: </Window>

Attach to command


  1:   public MainWindow()
  2:         {
  3:             InitializeComponent();
  4: 
  5:             // Query the registry to find out where the sample photos are stored.
  6: 
  7:             OperatorsModel theOperatorsModel = new OperatorsModel();
  8: 
  9:             theOperatorsModel.ShowOperatorCmd = new ShowOperatorCommand();
 10: 
 11:             this.DataContext = theOperatorsModel ;

The result
Capture8 
Resources:
http://msdn.microsoft.com/en-us/library/microsoft.surface.presentation.controls.elementmenu.activationhost.aspx
http://msdn.microsoft.com/en-us/library/ff727728.aspx

אין תגובות:

הוסף רשומת תגובה