Seemingly simple concept but can't get past this.
I have a Command...the _Executed method receives a KeyValuePair (types don't matter) as it's Parameter.
myCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
KeyValuePair<System.Type, MyCustomArgs> kvp = e.Parameter as KeyValuePair<Type, MyCustomArgs>;
:
:
:
}
Can't do that as it's non-nullable. How do I accomplish this? I want to extract the KeyValuePair from e.Parameter.
Appreciate any insight and will happily post more code/information if necessary.
You must use an explicit cast, rather than an implicit one, as you have done.
Implicit cast:
KeyValuePair<System.Type, MyCustomArgs> kvp = e.Parameter as KeyValuePair<Type, MyCustomArgs>;
Explicit cast:
KeyValuePair<System.Type, MyCustomArgs> kvp = (KeyValuePair<System.Type, MyCustomArgs>)e.Parameter;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With