in src/Microsoft.Xaml.Behaviors/Core/ChangePropertyAction.cs [359:409]
private object IncrementCurrentValue(PropertyInfo propertyInfo)
{
if (!propertyInfo.CanRead)
{
throw new InvalidOperationException(string.Format(
CultureInfo.CurrentCulture,
ExceptionStringTable.ChangePropertyActionCannotIncrementWriteOnlyPropertyExceptionMessage,
propertyInfo.Name));
}
object currentValue = propertyInfo.GetValue(this.Target, null);
object returnValue = currentValue;
Type propertyType = propertyInfo.PropertyType;
TypeConverter converter = TypeConverterHelper.GetTypeConverter(propertyInfo.PropertyType);
object value = this.Value;
if (value == null || currentValue == null)
{
// we can't increment by null, so we'll attempt to set it instead
// likewise, we can't increment, null by x, so we'll just set value instead
return value;
}
if (converter.CanConvertFrom(value.GetType()))
{
value = TypeConverterHelper.DoConversionFrom(converter, value);
}
if (typeof(double).IsAssignableFrom(propertyType))
{
returnValue = (double)currentValue + (double)value;
}
else if (typeof(int).IsAssignableFrom(propertyType))
{
returnValue = (int)currentValue + (int)value;
}
else if (typeof(float).IsAssignableFrom(propertyType))
{
returnValue = (float)currentValue + (float)value;
}
else if (typeof(string).IsAssignableFrom(propertyType))
{
returnValue = (string)currentValue + (string)value;
}
else
{
returnValue = TryAddition(currentValue, value);
}
return returnValue;
}