I want to pass an enum value as a CommandParameter. My enum is defined as:
public enum MyEnum
{
One,
Two
}
And in my axml I have:
local:MvxBind="Click MyCommand, CommandParameter=MyEnum.One"
...
local:MvxBind="Click MyCommand, CommandParameter=MyEnum.Two"
and MyCommand is defined in my ViewModel as
public IMvxCommand MyCommand
{
get { return new MvxCommand<MyEnum>(myfunction); }
}
private void myfunction(MyEnum p_enumParam)
{
switch (p_enumParam)
{
case MyEnum.One:
doSomething1();
break;
case MyEnum.Two:
doSomething2();
break;
}
}
When I run it, I get the error "System.InvalidCastException: Cannot cast from source type to destination type."
Obviously, because it cannot cast MyEnum.One and MyEnum.Two to the MyEnum type. So how can I convince it that MyEnum.One and MyEnum.Two are of MyEnum type?
Thanks, Pap