如果你要綁定到一個字符串,您可以定義的IValueConverter包內置的HighlightingDefinitionTypeConverter:
using System;
using System.Globalization;
using System.Windows.Data;
using ICSharpCode.AvalonEdit.Highlighting;
public class HighlightingDefinitionConverter : IValueConverter
{
private static readonly HighlightingDefinitionTypeConverter Converter = new HighlightingDefinitionTypeConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return Converter.ConvertFrom(value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Converter.ConvertToString(value);
}
}
然後,只需轉換器添加到您的綁定:
<avalonEdit:TextEditor Name="textEditor" SyntaxHighlighting="{Binding syntaxHighlighting, Converter={StaticResource HighlightingDefinitionConverter}}" />
它的工作原理,謝謝。 – 2013-05-06 05:50:23