Click here to Skip to main content
15,892,005 members
Articles / Desktop Programming / WPF

C# WPF .NET 4.0 ArrowRepeatButton, NumericUpDown, and TimeCtrl Controls

Rate me:
Please Sign up or sign in to vote.
4.39/5 (11 votes)
14 Oct 2011CPOL16 min read 67.4K   3.4K   16  
User controls for entering either a time or a number within a range.
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 UpDownCtrls
{
    /// <summary>
    /// Interaction logic for UpDownButtons.xaml
    /// </summary>
    public partial class UpDownButtons : UserControl
    {
        public static readonly RoutedEvent UpClickEvent = EventManager.RegisterRoutedEvent("UpClick",
                                     RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UpDownButtons));

        public event RoutedEventHandler UpClick
        {
            add { AddHandler(UpClickEvent, value); }
            remove { RemoveHandler(UpClickEvent, value); }
        }

        public static readonly RoutedEvent DownClickEvent = EventManager.RegisterRoutedEvent("DownClick",
                             RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UpDownButtons));

        public event RoutedEventHandler DownClick
        {
            add { AddHandler(DownClickEvent, value); }
            remove { RemoveHandler(DownClickEvent, value); }
        }
        public UpDownButtons()
        {
            InitializeComponent();
        }

        private void UpButton_Click(object sender, RoutedEventArgs e)
        {
            RoutedEventArgs UpClickEventArgs = new RoutedEventArgs(UpClickEvent);
            RaiseEvent(UpClickEventArgs);
        }

        private void DownButton_Click(object sender, RoutedEventArgs e)
        {
            RoutedEventArgs DownClickEventArgs = new RoutedEventArgs(DownClickEvent);
            RaiseEvent(DownClickEventArgs);
        }
    }
}

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
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions