Skip to content

Possible to not allow NaN on NumberBox? #8399

Answered by Trix07
dbriard asked this question in Q&A
Discussion options

You must be logged in to vote

You're right, I wasn't aware of that! Sorry for being misleading.

There is an alternative solution that involves creating a custom IValueConverter that operates on the same principle. This converter returns 0 if the value passed to it is either NaN or null. You can then use this converter when binding the NumberBox value to the Slider value.

By using this approach, the NumberBox can still be empty while the Slider will default to 0. However, if it is necessary for the NumberBox to never be empty, then perhaps try to do the validation on the ValueChanged event.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@dbriard
Comment options

@Trix07
Comment options

Answer selected by dbriard
@dbriard
Comment options

Comment options

You must be logged in to vote
1 reply
@Trix07
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants