Skip to content

Commit

Permalink
Update ChangeTypeConverter.cs (Windows-XAML#1186)
Browse files Browse the repository at this point in the history
Checking for IsInstanceOfType instead of object so objects from derived classes don't throw an exception when System.Convert.ChangeType (e.g. when IConvertible is not implemented) is called.
  • Loading branch information
helmut-steiner authored and JerryNixon committed Aug 23, 2016
1 parent 6fbe281 commit e5f6e5c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Template10 (Library)/Converters/ChangeTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public object Convert(object value, Type targetType, object parameter, string la
if (value == null && targetType.GetTypeInfo().IsValueType)
return Activator.CreateInstance(targetType);

if (targetType == typeof(object))
return (object)value;
if (targetType.IsInstanceOfType(value))
return value;

return System.Convert.ChangeType(value, targetType);
}
Expand Down

0 comments on commit e5f6e5c

Please sign in to comment.