MaterialDesignInXamlToolkit icon indicating copy to clipboard operation
MaterialDesignInXamlToolkit copied to clipboard

MathMultipleConverter can throw Exceptions e.g. at DesignTime

Open uPloraX opened this issue 10 years ago • 2 comments

The MathMultipleConverter throws a NullReferenceExceptionat DesignTime when I used it for a Style, because a referenced value wasn't created yet.

The converter tries to convert the values .ToString(), even when there are null-> Exception

if (Double.TryParse(value[0].ToString(), out value1) && Double.TryParse(value[1].ToString(), out value2))

You can just fix this by adding this at the top or surround it with a try:

if (values[0] == null || values[1] == null) return Binding.DoNothing;

uPloraX avatar Aug 09 '16 12:08 uPloraX

I hope that PR #464 will help you after merging.

spiegelp avatar Aug 12 '16 13:08 spiegelp

Yep, your changes seems great, better to avoid all those possible Exceptions than just using a try/catch. Till the package is updated I implemented a copy by myself, thanks for your effort!

uPloraX avatar Aug 14 '16 20:08 uPloraX