Press F1 to get help : Event « Windows Presentation Foundation « C# / C Sharp






Press F1 to get help

Press F1 to get help
   
<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Press F1 to get help" Height="250" Width="400">
  <DockPanel>
    <Menu DockPanel.Dock ="Top" HorizontalAlignment="Left" Background="White">
      <MenuItem Header="_Edit">
        <MenuItem Command ="Copy"/>
        <MenuItem Command ="Cut"/>
        <MenuItem Command ="Paste"/>
      </MenuItem>
    </Menu>
    <TextBox AcceptsReturn ="True" Foreground ="Black" Background ="AliceBlue"></TextBox>
  </DockPanel>   
</Window>
//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApplication1
{
  public partial class MainWindow : System.Windows.Window
  {
    public MainWindow()
    {
      InitializeComponent();

      CommandBinding helpBinding = new CommandBinding(ApplicationCommands.Help);
      helpBinding.CanExecute += CanHelpExecute;
      helpBinding.Executed += HelpExecuted;
      CommandBindings.Add(helpBinding);
    }

    private void CanHelpExecute(object sender, CanExecuteRoutedEventArgs e)
    {
      e.CanExecute = true;
    }
    private void HelpExecuted(object sender, ExecutedRoutedEventArgs e)
    {
      MessageBox.Show("support", "Help!");
    }
  }
}

   
    
    
  








Related examples in the same category

1.Cast event sender to a controlCast event sender to a control
2.Raise the PropertyChanged eventRaise the PropertyChanged event
3.Get the event sender nameGet the event sender name
4.Use Ellipse event delegateUse Ellipse event delegate
5.Halting event routing with HandledHalting event routing with Handled
6.Use Ellipse.AddHandler to add handler to Ellipse objectsUse Ellipse.AddHandler to add handler to Ellipse objects
7.Get event sender from eventGet event sender from event
8.Handle the ContentRendered eventHandle the ContentRendered event
9.Find source element of an element in event handler by casintFind source element of an element in event handler by casint
10.Add an event handler to an element using codeAdd an event handler to an element using code
11.Handles the Click event on the UniformGridHandles the Click event on the UniformGrid
12.Mark the text control as being changed to prevent any text content or selection changed eventsMark the text control as being changed to prevent any text content or selection changed events
13.Check handler event senderCheck handler event sender
14.Generate Click Events Repeatedly While a Button Is ClickedGenerate Click Events Repeatedly While a Button Is Clicked
15.Raise the ScrollChanged event of a ScrollViewerRaise the ScrollChanged event of a ScrollViewer
16.Event firing sequenceEvent firing sequence
17.ToolBar and event handlerToolBar and event handler
18.Cancel event by setting CanExecute and Handled to falseCancel event by setting CanExecute and Handled to false
19.Activated and Deactivated events monitors the activation status of an application.
20.Event sender, event source and event original sourceEvent sender, event source and event original source
21.Attach a double click to an object