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.

2
  • Show some clear code, how you try to add the control. The namespace and how you adding it etc Commented Nov 3, 2015 at 4:19
  • Does this answer your question? Where is the WPF Numeric UpDown control? Commented Mar 27, 2021 at 21:13

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.