HTML Convert
In this case both properties are of type string, so the converter trick is not really needed. However, here we use the converter to strip out HTML markup and clean up the text to display. Again, the converter class needs to be declared as a resource, as shown above.
public class HtmlSanitizer : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
// Remove HTML tags and empty newlines and spaces
string returnString = Regex.Replace(value as string, "<.*?>", "");
returnString = Regex.Replace(returnString, @"\n+\s+", "\n\n");
// Decode HTML entities
returnString = HttpUtility.HtmlDecode(returnString);
return returnString;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
'WPF' 카테고리의 다른 글
[INotifyPropertyChanged ] 초간단 상태변경 알림 구현하기 (2) | 2010.05.28 |
---|---|
Silverlight Beta 4 Drag n Drop Feature(Picture album) (0) | 2010.05.15 |
[WPF]초간단 윈도우즈 창 Drag(드래그) 하기 (0) | 2010.04.14 |
[MSDN]BindingSource와 INotifyPropertyChanged 인터페이스를 사용하여 변경 내용 알림 발생 (0) | 2010.04.07 |
실버라이트로 windows mobile 7 프로그램 개발 (0) | 2010.03.17 |
ObservableCollection<(Of <(T>)>) Class (0) | 2010.01.02 |
INotifyPropertyChanged (0) | 2010.01.02 |
Using Value Converters (0) | 2010.01.02 |
DataGrid 템플릿 (0) | 2010.01.02 |
간단한 data grid 사용법 (0) | 2010.01.02 |