How to create a SingleEditBox

Editors for WPF Forum

Posted 8 years ago by Mark Foti
Version: 12.2.0573
Dear Actipro-Team,
I would like to bind a float variable to a DoubleEditBox. The problem is that the conversion from float to double modifies the value slightly, such that the float value 0.15 becomes 0.15000000596046448. To avoid this I would like to use a SingleEditBox that binds a float value instead of a double value.
So I derived from ActiproSoftware.Windows.Controls.Editors.Primitives.DoubleEditBoxBase and put Nullable<float> as generic parameter.
public class SingleEditBox : ActiproSoftware.Windows.Controls.Editors.Primitives.DoubleEditBoxBase<Nullable<float>>
However, this did not workout correctly, as the resulting EditBox is readonly and does not show any value. So I was wondering what is missing. Can you please help me with that.
Best regards

Comments (1)

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

Hi Micheal,

Yeah, unfortunately it would not be that simple to create an EditBox for floats (aka Single). There's a bit more plumbing needed in order to support it. I've marked down a TODO item to add this control in the future.

If you know you only want a certain precision, then you set the Format property so it only displays that many digits (i.e. use "F2"). Then when converting from a double to a float, you would need to try to chop off the extraneous digits. This could be done in an IValueConverter as well.

Actipro Software Support

The latest build of this product (v2020.1.0) was released 27 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.