|
|
@ -337,14 +337,19 @@ namespace Microsoft.Windows.Controls |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private bool _convertExceptionOccurred = false; |
|
|
|
|
|
|
|
|
private object ConvertTextToValue(string text) |
|
|
private object ConvertTextToValue(string text) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
object convertedValue = null; |
|
|
object convertedValue = null; |
|
|
|
|
|
|
|
|
Type dataType = ValueType; |
|
|
Type dataType = ValueType; |
|
|
|
|
|
|
|
|
string valueToConvert = MaskProvider.ToString().Trim(); |
|
|
string valueToConvert = MaskProvider.ToString().Trim(); |
|
|
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
if (valueToConvert.GetType() == dataType || dataType.IsInstanceOfType(valueToConvert)) |
|
|
if (valueToConvert.GetType() == dataType || dataType.IsInstanceOfType(valueToConvert)) |
|
|
{ |
|
|
{ |
|
|
convertedValue = valueToConvert; |
|
|
convertedValue = valueToConvert; |
|
|
@ -364,6 +369,13 @@ namespace Microsoft.Windows.Controls |
|
|
{ |
|
|
{ |
|
|
convertedValue = Convert.ChangeType(valueToConvert, dataType); |
|
|
convertedValue = Convert.ChangeType(valueToConvert, dataType); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
catch |
|
|
|
|
|
{ |
|
|
|
|
|
//if an excpetion occurs revert back to original value
|
|
|
|
|
|
_convertExceptionOccurred = true; |
|
|
|
|
|
return Value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return convertedValue; |
|
|
return convertedValue; |
|
|
} |
|
|
} |
|
|
@ -373,6 +385,12 @@ namespace Microsoft.Windows.Controls |
|
|
if (value == null) |
|
|
if (value == null) |
|
|
value = string.Empty; |
|
|
value = string.Empty; |
|
|
|
|
|
|
|
|
|
|
|
if (_convertExceptionOccurred) |
|
|
|
|
|
{ |
|
|
|
|
|
value = Value; |
|
|
|
|
|
_convertExceptionOccurred = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//I have only seen this occur while in Blend, but we need it here so the Blend designer doesn't crash.
|
|
|
//I have only seen this occur while in Blend, but we need it here so the Blend designer doesn't crash.
|
|
|
if (MaskProvider == null) |
|
|
if (MaskProvider == null) |
|
|
return value.ToString(); |
|
|
return value.ToString(); |
|
|
|