views:

794

answers:

2
A: 

Maybe, at this time, parameter is null ?

Win4ster
+2  A: 

It seems that the RelayCommand will cast the value the parameter to the generic T.

But you cannot cast a null to a struct, as the exception tells you!

If you initialize the RelayCommand with a nullable struct, it will work as expected!

RelayCommand<int?> or RelayCommand<Nullable<int>>

HTH

Arcturus
Uhm, that should be the reason... But it is a little weird.. I didn't see any code using nullable ...
Jesus Rodriguez
Yes that is correct.. a `double` or `int` are value types, and cannot be null. If you make them nullable types, it should work. Casting `null` to a struct will produce an exception! See Vlads comment with the method where you can see the cast to T!
Arcturus
try compiling double test = (double)null;.. in the generic world you will get a runtime exception! ;)
Arcturus