0

I'm just learning C# and am following a tutorial.

The tutorial was written for VS2013, but I am doing it in VS15 (Community). It says to drag a NumericUpDown object in from the toolbox in the designer window but it is not listed. I've tried right clicking and looking in the "Choose Items" dialog and, in fact, NumericUpDown is listed and checked but doesn't show up in the toolbox list. All google searches I've found have people saying it shows up but grayed out, mine isn't even there, let alone grayed out. I'm working in a WPF project.

Any suggestions?

  • http://stackoverflow.com/questions/841293/where-is-the-wpf-numeric-updown-control – Sarvesh Mishra Aug 29 '16 at 06:26
  • NumericUpdown is for WinForm Application, not for WPF. – Sarvesh Mishra Aug 29 '16 at 06:27
  • Ahhh. Sure enough. If only I would read the fine print on the tutorial. (I did, about a dozen times). Funny how things only stand out when you're looking for them specifically. Thank you! Maybe I'm getting ahead of myself, but if I wanted to use a NumericUpDown in a WPF, how would I go about it? – pearldrumbum Aug 29 '16 at 06:36

1 Answers1

1

Since WPF doesn't have a standart NumericUpDown element we have to create one ourselfs:

below i posted a sample, the Original is here: CodeProject

 <Grid Margin="1">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="20" />
    </Grid.ColumnDefinitions>

    <TextBox Name="TextBoxValue"
             TextAlignment="Right"
             Grid.Column="0"/>
    <StackPanel Orientation="Vertical"
    Grid.Column="1"
    VerticalAlignment="Center">
        <Button Name="btnIncrease"
                Click="Increase">
            <Image Source="Images/up.png" Height="3" Width="5"  />
        </Button>
        <Button Name="btnDecrease"
                Click="Decrease">
            <Image Source="Images/down.png" Height="3" Width="5" />
        </Button>
    </StackPanel>
</Grid> 

This will create a textbox with two buttons on the right side with up/down arrows(dont forget the images for the buttons)

The easiest way to implement this, is to build a class and add it to youre toolbox. After you did that you can just use the NumericUpDown control like a basic WinForm application.

BUT you have to write the code behind for this.

mbx
  • 6,292
  • 6
  • 58
  • 91
Giellez
  • 146
  • 1
  • 7