Tag: avalonedit

使用MVVM双向绑定到AvalonEdit文档文本

我想在我的MVVM应用程序中包含一个AvalonEdit TextEditor控件。 我需要的第一件事是能够绑定到TextEditor.Text属性,以便我可以显示文本。 为此,我遵循了Make AvalonEdit MVVM兼容的示例。 现在,我已使用接受的答案作为模板实现了以下类 public sealed class MvvmTextEditor : TextEditor, INotifyPropertyChanged { public static readonly DependencyProperty TextProperty = DependencyProperty.Register(“Text”, typeof(string), typeof(MvvmTextEditor), new PropertyMetadata((obj, args) => { MvvmTextEditor target = (MvvmTextEditor)obj; target.Text = (string)args.NewValue; }) ); public new string Text { get { return base.Text; } set { base.Text = value; } } […]

AvalonEdit WPF TextEditor(SharpDevelop):如何突出显示特定范围的文本?

令人难以置信的令人敬畏的AvalonEdit WPF TextEditor控件似乎缺少一个重要的function,或者至少我无法弄明白。 给定偏移量和长度,使用HighlightColor突出显示TextDocument中的该部分 。 简单吧? 显然不是。 我有RTFM,关于“语法突出显示”的文档让我更加困惑。 其他人在SharpDevelop论坛上提出同样的问题,我恐怕无法理解Herr Grunwald的回答。 这是我的尝试,使用DocumentHighlighter类(当然它不起作用): textEditor1.Text = “1234567890”; HighlightingColor c = new HighlightingColor() { FontWeight = FontWeights.ExtraBold }; DocumentHighlighter dh = new DocumentHighlighter(textEditor1.Document, new HighlightingRuleSet()); HighlightedLine hl = dh.HighlightLine(1); hl.Sections.Add(new HighlightedSection() { Color = c, Offset = 1, Length = 3 }); 谢谢你的帮忙!

如何将此WPF控件添加到我的WinForm中?

我知道我必须使用ElementHost在WinForm中显示WPF控件,但由于WPF控件是第三方软件,它只附带一个XML文件和一个DLL文件。 控件是AvalonEdit ,我将ICSharpCode.AvalonEdit.xml和ICSharpCode.AvalonEdit.dll文件添加到我的项目中,然后我转到Project -> Add Reference并添加了DLL作为参考。 现在我可以在我的代码中访问ICSharpCode命名空间,所有的类和方法都暴露出来,但从这一点来说,我不确定如何在我的WinForm中实际使用该控件。 我期待WPF控件出现在解决方案资源管理器中,但事实并非如此。 我尝试将一个ElementHost控件添加到我的WinForm中,但是当我尝试选择托管内容时,没有控件出现,所以它不知道我的WPF控件。 如何在WinForm中使用AvalonEdit WPF控件?

AvalonEdit中的双向绑定不起作用

我在我的项目中使用了AvalonEdit,它基于WPF和MVVM。 看完这篇文章后,我创建了以下课程: public class MvvmTextEditor : TextEditor, INotifyPropertyChanged { public static DependencyProperty DocumentTextProperty = DependencyProperty.Register(“DocumentText”, typeof(string), typeof(MvvmTextEditor), new PropertyMetadata((obj, args) => { MvvmTextEditor target = (MvvmTextEditor)obj; target.DocumentText = (string)args.NewValue; }) ); public string DocumentText { get { return base.Text; } set { base.Text = value; } } protected override void OnTextChanged(EventArgs e) { RaisePropertyChanged(“DocumentText”); base.OnTextChanged(e); […]

使AvalonEdit MVVM兼容

我正在尝试在我的WPF应用程序中使Avalon MVVM兼容。 从谷歌搜索,我发现AvalonEdit不是MVVM友好的 ,我需要通过创建一个派生自TextEditor的类然后添加必要的依赖属性来导出AvalonEdit的状态。 我担心格伦沃尔德先生在这里的回答让我很失落: 如果你真的需要使用MVVM导出编辑器的状态,那么我建议你创建一个派生自TextEditor的类,它添加必要的依赖属性并将它们与AvalonEdit中的实际属性同步。 有没有人有一个例子或有关如何实现这一目标的好建议?