What is easiest/best way to create Int16EditBox control?

Editors for WPF Forum

Posted 8 years ago by Brad Salmon
Version: 16.1.0631

We are using MVVM pattern. We want the data types in the VM to align with data types in the model, which means we have numerous Int16 properties. When we use the Int32EditBox control and bind to an Int16? property we get some "errors" in the VS Debug Output window. Everything "works" (i.e. the app runs and values ultimately seem to be correct), but we'd like to eliminate the debug errors/messages.

So, we want to create an Int16EditBox that is just like the Int32EditBox control but for Int16. I had hoped I could just create a control and inherit from RangeTypeSpecificEditBoxBase<Int16> but then I didn't know if I needed to completely copy the Style definition or if there was an easy way to have the Int16EditBox style utilize the existing Int32EditBox style. I'm hoping I just did something wrong (I'm no WPF expert).

Looking for input on what the best way to accomplish getting an Int16EditBox control created.


- Brad

Comments (1)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Brad,

It's a fairly complicated process to create another whole edit box for numbers since there's a lot of codebehind for parts that is needed.  Instead of doing that, I would recommend using Int32EditBox.  You could create a Style that you use for Int16 scenarios where you set the Maximum value to the highest Int16 value.  Then make a value converter that converts between Int32 and Int16 and bind your Int16 value to the Int32EditBox.Value using that converter.  I would think that doing those things would get you working without errors.

Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.