Use DoubleEditBox, type simple Mathematical Expression

Editors for WPF Forum

Posted 6 years ago by Tom P.
Version: 13.2.0591
Avatar

I'm attempting to reproduce some legacy C++ MFC UI controls. One feature is the ability for the User to type in either a double value, or, a mathematical expression like "1 + 200mm - 9in".  Parsing the expression will be entirely up to my own code. And no, telling the user to use the Calculator drop down isn't going to cut it since the expression can have some pre-defined domain specific variables in it also.

The DoubleEditBox limits input, so using anything but digits, and decimals is prohibited.

Any thoughts on how I might get this functionality to work with any of the Editor Controls?

 

Thanks!

Comments (4)

Posted 6 years ago by Tom P.
Avatar

I've created a custom IValueConverter and put it on an Editor.TextBox and that works ok. I just lose a whole lot of stuff that DoubleEditBox gives me

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

Hi Tom,

Unfortunately in this case, none of the editors as-is will work for you.  They are designed to only bind to a single value and don't have any support for expressions or any free-form entry.  That would require a custom control to accomplish (or what you did with TextBox) but we don't have anything in that area right now.  Sorry!


Actipro Software Support

Posted 6 years ago by Tom P.
Avatar

Hmm, I was afraid of that.

I've looked at the inheritance hierarchy of DoubleEditBox, and I was hoping to find a particular base class to start with. However, I'm not sure if that would be a good place to start on a custom control for this.

Do you think there is a good Actipro Editor base class I should use?  I don't know which class is doing the input filtering that DoubleEditBox has to only allow double value text input.

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

Hi Tom,

You should take a look at the "CustomPartEditBoxSSN" QuickStart.  That shows a good example of creating a custom part edit box.  In your case you might want the edit box to inherit TypeSpecificEditBoxBase<double> and then generate a custom part group and part that can handle your expression parsing.  You can implement ISpinnable on the part to allow spinners too, similar to the DoubleEditBox.  I hope that helps!


Actipro Software Support

The latest build of this product (v2019.1 build 0682) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.