0

I am trying to add a NumericUpDown to my WPF window at design time in Visual Studio 2013. So far I simply have:

<NumericUpDown/>

Which gives me the Error: NumericUpDown is not supported in a Window Presentatio Foundation (WPF) project.

I think I'm misunderstanding something about namespaces in XAML, I've tried to add the full namespace but that still gets the same error. All the help I see online is older and is about building your own.

Community
  • 1
  • 1
Knells
  • 827
  • 2
  • 12
  • 24
  • Show some clear code, how you try to add the control. The namespace and how you adding it etc – Siva Gopal Nov 03 '15 at 04:19
  • Does this answer your question? [Where is the WPF Numeric UpDown control?](https://stackoverflow.com/questions/841293/where-is-the-wpf-numeric-updown-control) – T.Todua Mar 27 '21 at 21:13

2 Answers2

4

You can not directly use Winforms control(based on link in your question to NumericUpDown) in WPF. To do that you need to use WindowsFormsHost control and inside this use the WinForm controls

So to get the NumericUpDown in wpf you need to do below steps:

Add a reference to your WPF project to System.Windows.Forms and import in case of XAML like:

xmlns:winforms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"

Render the control:

<StackPanel>
   <WindowsFormsHost>
       <winforms:NumericUpDown />
   </WindowsFormsHost>
</StackPanel>

You can learn more on this from MSDN for XAML and Code Behind (C#/VB)

Hope this give you some idea to start with, if this is the route you want to do it.

Siva Gopal
  • 3,474
  • 1
  • 25
  • 22
3

By default, there is no NumericUpDown control.

There is, however, a NumericUpDown-like control included in the wpftoolkit.
It's called IntegerUpDown. There is also a DecimalUpDown and a DoubleUpDown.

Edit: Updated link since Codeplex has been down for some time now.

SplittyDev
  • 551
  • 1
  • 10
  • 19