ButtonSpinner

Derives from Xceed.Wpf.Toolkit.Spinner

The ButtonSpinner control allows you to add button spinners to any element and then respond to the Spin event to manipulate that element. The Spin event lets the developer know which direction the buttons are spinning; SpinDirection.Increase indicates an increment, SpinDirection.Decrease indicates a decrement.

buttonspinner.png

You can wrap any element by placing it inside the content area of the ButtonSpinner control. As an example, lets create our own simple numeric up/down control

buttonspinner_numeric.png

XAML
        <xctk:ButtonSpinner Spin="ButtonSpinner_Spin">
            <TextBox Text="0" HorizontalContentAlignment="Right" />
        </xctk:ButtonSpinner>


Code Behind
        private void ButtonSpinner_Spin(object sender, Microsoft.Windows.Controls.SpinEventArgs e)
        {
            ButtonSpinner spinner = (ButtonSpinner)sender;
            TextBox txtBox = (TextBox)spinner.Content;

            int value = String.IsNullOrEmpty(txtBox.Text) ? 0 : Convert.ToInt32(txtBox.Text);
            if (e.Direction == Microsoft.Windows.Controls.SpinDirection.Increase)
                value++;
            else
                value--;
            txtBox.Text = value.ToString();
        }

Properties

Property Description
AllowSpin Gets or sets a value indicating whether the spinner buttons are enabled.
Content Gets or sets the content of the ButtonSpinner.
ShowButtonSpinner Gets or sets a value indicating whether the ButtonSpinner is visible.
ValidSpinDirection Gets or sets the valid direction for the Spinner (None, Increase or Decrease). By default, Increase or Decrease. (Inherited from Spinner)

Events

Event Description
Spin Raised when spinning is initiated by the end-user. (Inherited from Spinner)


Support this project, check out the Plus Edition.
---

Last edited Jun 9 at 6:25 PM by dlafontaine, version 10

Comments

SuperJMN Oct 16, 2012 at 8:31 PM 
What is the best way to use this in a MVVM manner?

timhibbard May 8, 2012 at 7:22 PM 
I found an issue with the default padding when using without content. Here is the post about it:
http://timhibbard.com/blog/2012/05/08/default-padding-issue-with-buttonspinner/