Click here to Skip to main content
15,893,644 members
Articles / Desktop Programming / WPF

A Simple Cross Button for WPF

Rate me:
Please Sign up or sign in to vote.
4.89/5 (17 votes)
18 Aug 2011CPOL3 min read 78.4K   3.6K   53  
A small and simple cross button for your WPF applications.
using System;
using System.Collections.Generic;
using System.Linq;
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.Navigation;
using System.Windows.Shapes;

namespace Example
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            viewModel.AddCharacterCommand.Executed += new Apex.MVVM.CommandEventHandler(AddCharacterCommand_Executed);
        }

        /// <summary>
        /// Handles the Executed event of the AddCharacterCommand command.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="Apex.MVVM.CommandEventArgs"/> instance containing the event data.</param>
        void AddCharacterCommand_Executed(object sender, Apex.MVVM.CommandEventArgs args)
        {
            //  Focus the name box so that we can type a new name in straight away.
            nameBox.Focus();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.

Comments and Discussions