DoubleEditBox Delete?

Editors for WPF Forum

Posted 15 years ago by Brette Esterbrooks
Version: 9.1.0506

I have the following xaml. If I enter and amount say, 100.00 and then tab away and enter some other values. Then come back to this field and click the delete button the value is not bound back to the binding source. This causes the original value to be saved even though the user has deleted the value from the text doubleEditBox. Is there something I can do to make sure the binding is updated when the delete button is pressed?

<Editors:DoubleEditBox Grid.Row="0"
    Value="{Binding Path=ActivityRate.RateAmount, ValidatesOnDataErrors=True,  UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />

Comments (4)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Brette,

I don't see where you add a delete button into the DoubleEditBox, so I'm not exactly sure what you mean.

Keep in mind that the DoubleEditBox will not change the Value if you delete all the text because you have IsNullAllowed set to false. if you set IsNullAllowed to true and delete all the text, then the Value will be set to null.

Actipro Software Support

Posted 15 years ago by Brette Esterbrooks
Sorry I should have been more clear. What I meant was when the user clicks the Delete KEY on the keyboard clearing out all of the text the null value is not being bound to my source property.

Setting IsNullAllowed equal to True seems a bit odd since doubles cannot assigned to null. And when I tried this the value is still not being bound back to the source property probably because it cannot be.

Oddly I see no binding errors such as (value type cannot be assigned null) so I can only assume the control is deciding not to attempt the bind when the target is valued with null and the source is a CLR value type.

What I would like to see i this.

User deletes all content in text box control sends default(double) or in my case 0.0.

Any insight?

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Brette,

The DoubleEditBox.Value is actually a "double?", which means it can be set to null. This offers the most flexiblity as it can be bound to double values, as well as double? values.

Since the source of your Binding is a double, then clearly a null value can't be pushed back from our control. But our control isn't doing anything special to prevent the binding from updating your value. If you bould a TextBlock's Text property to the DoubleEditBox's Value, you could verify this.

So you have a couple of options, you can:

1. Use a custom IValueConverter in your binding, that converts null to 0 in the ConvertBack method.

The draw back to this is that the control will not display as "0", but you could set NullContent to say "default" so it has a unique "default value" look.

2. You can handle the ValueChanging event, and update the e.NewValue to be 0 whenever e.NewValue is null.

Hope this helps.

Actipro Software Support

Posted 15 years ago by Brette Esterbrooks
Thanks that clears things up. I appreciate the fast response!
The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.