private string ConvertValueToText(object value) { if (value == null) { 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. if (MaskProvider == null) { return(value.ToString()); } MaskProvider.Set(value.ToString()); return(MaskProvider.ToDisplayString()); }
private void Paste(object sender, RoutedEventArgs e) { if (IsReadOnly) { return; } object data = Clipboard.GetData(DataFormats.Text); if (data != null) { string text = data.ToString().Trim(); if (text.Length > 0) { int position = SelectionStart; MaskProvider.Set(text); UpdateText(position); } } }