Where is the WPF Numeric UpDown control?
I made my own;
the xaml
<Grid Height="23" Margin="152,63,11,0" VerticalAlignment="Top">
<TextBox x:Name="txtNum" x:FieldModifier="private" Text="0" TextChanged="txtNum_TextChanged" Margin="3,2,13,3" />
<Button x:Name="cmdUp" x:FieldModifier="private" FontSize="10" Padding="0,-4,0,0" Content="▲" Width="10" Click="cmdUp_Click" Margin="33,2,1,13" />
<Button x:Name="cmdDown" x:FieldModifier="private" FontSize="10" Padding="0,-4,0,0" Content="▼" Width="10" Click="cmdDown_Click" Margin="33,12,1,3" />
</Grid>
and the code behind
private int _numValue = 0;
public int NumValue
{
get { return _numValue; }
set
{
_numValue = value;
txtNum.Text = value.ToString();
}
}
public NumberUpDown()
{
InitializeComponent();
txtNum.Text = _numValue.ToString();
}
private void cmdUp_Click(object sender, RoutedEventArgs e)
{
NumValue++;
}
private void cmdDown_Click(object sender, RoutedEventArgs e)
{
NumValue--;
}
private void txtNum_TextChanged(object sender, TextChangedEventArgs e)
{
if (txtNum == null)
{
return;
}
if (!int.TryParse(txtNum.Text, out _numValue))
txtNum.Text = _numValue.ToString();
}
Simply use the IntegerUpDown
control in the Extended.Wpf.Toolkit
You can use it like this:
Add to your XAML the following namespace:
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
In your XAML where you want the control use:
<xctk:IntegerUpDown Name="myUpDownControl" />