diff --git a/Perspex.Base/PerspexProperty.cs b/Perspex.Base/PerspexProperty.cs
index 17850e8631..e6184ca510 100644
--- a/Perspex.Base/PerspexProperty.cs
+++ b/Perspex.Base/PerspexProperty.cs
@@ -346,21 +346,21 @@ namespace Perspex
/// True if the value is valid, otherwise false.
public bool IsValidValue(object value)
{
- if (value == UnsetValue)
- {
- return true;
- }
- else if (value == null)
- {
- return !this.PropertyType.GetTypeInfo().IsValueType ||
- Nullable.GetUnderlyingType(this.PropertyType) != null;
- }
+ return PriorityValue.IsValidValue(value, this.PropertyType);
+ }
- return this.PropertyType.GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo());
+ ///
+ /// Overrides the default value for the property on the specified type.
+ ///
+ /// The type.
+ /// The default value.
+ public void OverrideDefaultValue(object defaultValue)
+ {
+ this.OverrideDefaultValue(typeof(T), defaultValue);
}
///
- /// Gets the default value for the property on the specified type.
+ /// Overrides the default value for the property on the specified type.
///
/// The type.
/// The default value.
@@ -368,7 +368,15 @@ namespace Perspex
{
Contract.Requires(type != null);
- // TODO: Ensure correct type.
+ if (!this.IsValidValue(defaultValue))
+ {
+ throw new InvalidOperationException(string.Format(
+ "Invalid value for Property '{0}': {1} ({2})",
+ this.Name,
+ defaultValue,
+ defaultValue.GetType().FullName));
+ }
+
if (this.defaultValues.ContainsKey(type))
{
throw new InvalidOperationException("Default value is already set for this property.");