ToolBar and event handler : Event « Windows Presentation Foundation « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Windows Presentation Foundation » Event 
24.119.18.ToolBar and event handler
<Window x:Class="Commands.TwoDocument"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="TwoDocument" Height="300" Width="300">

  <Window.Resources>
    <CommandBinding x:Key="binding" Command="ApplicationCommands.Save" Executed="SaveCommand" CanExecute="SaveCommand_CanExecute" />
  </Window.Resources>

  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"></RowDefinition>
      <RowDefinition Height="Auto"></RowDefinition>
      <RowDefinition></RowDefinition>
      <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <ToolBarTray Grid.Row="1">
      <ToolBar>
        <Button Command="New">New</Button>
        <Button Command="Open">Open</Button>
        <Button Command="Save">Save</Button>
      </ToolBar>
      <ToolBar>
        <Button Command="Cut">Cut</Button>
        <Button Command="Copy">Copy</Button>
        <Button Command="Paste">Paste</Button>
      </ToolBar>
    </ToolBarTray>
    <TextBox Margin="5" Grid.Row="2" TextWrapping="Wrap" AcceptsReturn="True" TextChanged="txt_TextChanged">
      <TextBox.CommandBindings>
        <StaticResource ResourceKey="binding"></StaticResource>
      </TextBox.CommandBindings>
      
    </TextBox>

  </Grid>
</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 Commands
{
    public partial class TwoDocument : System.Windows.Window
    {
        public TwoDocument()
        {
            InitializeComponent();
        }

        private void SaveCommand(object sender, ExecutedRoutedEventArgs e)
        {            
        }
        private void txt_TextChanged(object sender, RoutedEventArgs e)
        {
        }
        private void SaveCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = false;
        }
    }
}
WPF Tool Bar And Event Handler
24.119.Event
24.119.1.Cast event sender to a controlCast event sender to a control
24.119.2.Press F1 to get helpPress F1 to get help
24.119.3.Raise the PropertyChanged eventRaise the PropertyChanged event
24.119.4.Get the event sender nameGet the event sender name
24.119.5.Use Ellipse event delegateUse Ellipse event delegate
24.119.6.Halting event routing with HandledHalting event routing with Handled
24.119.7.Use Ellipse.AddHandler to add handler to Ellipse objectsUse Ellipse.AddHandler to add handler to Ellipse objects
24.119.8.Get event sender from eventGet event sender from event
24.119.9.Handle the ContentRendered eventHandle the ContentRendered event
24.119.10.Find source element of an element in event handler by casintFind source element of an element in event handler by casint
24.119.11.Add an event handler to an element using codeAdd an event handler to an element using code
24.119.12.Handles the Click event on the UniformGridHandles the Click event on the UniformGrid
24.119.13.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
24.119.14.Check handler event senderCheck handler event sender
24.119.15.Generate Click Events Repeatedly While a Button Is ClickedGenerate Click Events Repeatedly While a Button Is Clicked
24.119.16.Raise the ScrollChanged event of a ScrollViewerRaise the ScrollChanged event of a ScrollViewer
24.119.17.Event firing sequenceEvent firing sequence
24.119.18.ToolBar and event handlerToolBar and event handler
24.119.19.Cancel event by setting CanExecute and Handled to falseCancel event by setting CanExecute and Handled to false
24.119.20.Activated and Deactivated events monitors the activation status of an application.Activated and Deactivated events monitors the activation status of an application.
24.119.21.Event sender, event source and event original sourceEvent sender, event source and event original source
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.