I have a textbox that is bound to an Integer property. when the user enters something in the textbox that can\'t be converted to an integer (eg. name) an exception will be t
Consider calling the command from the view model instead of from the view.
private int _myProperty;
public int MyProperty
{
get
{
return _myProperty;
}
set
{
_myProperty = value;
// See if the value can be parsed to an int.
int potentialInt;
if(int.TryParse(_myProperty, out potentialInt))
{
// If it can, execute your command with any needed parameters.
yourCommand.Execute(_possibleParameter)
}
}
}
This will allow you to handle the user typing things that cannot be parsed to an integer, and you will only fire the command when what the user typed is an integer.
(I didn't test this code, but I think it might be helpful.)