Thursday, November 6, 2014

Direct event in WPF application using c#

11:23 AM - By azeheruddin khan 0

Explanation: - The event which is handled only by the event handler of source element of the element tree is called as Direct event.

 Program to show Direct event

Page1.xaml

<Page x:Class="WPF_examples.Page1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"
 Title="Page1">

    <Grid Height="102" Width="209">
        <Button Content="CANCEL" Name="cancel"  Height="48" HorizontalAlignment="Left" Margin="43,32,0,0" VerticalAlignment="Top" Width="119" MouseMove="cancel_MouseMove" />
    </Grid>
</Page>


Page1.xaml.cs (code behind the xaml page)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace WPF_examples
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Page1 : Page
    {
        public Page1()
        {
            InitializeComponent();
        }

        private void cancel_MouseMove(object sender, MouseEventArgs e)
        {
            MessageBox.Show("Mouse is moved over cancel button");
        }        
    }
}

OutPut:








About the Author

I am Azeheruddin Khan having more than 6 year experience in c#, Asp.net and ms sql.My work comprise of medium and enterprise level projects using asp.net and other Microsoft .net technologies. Please feel free to contact me for any queries via posting comments on my blog,i will try to reply as early as possible. Follow me @fresher2programmer
View all posts by admin →

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

adsense

© 2014 Fresher2Programmer. WP Theme-junkie converted by Bloggertheme9
Powered by Blogger.
back to top