在托管的WPF复合控件中的奇怪的滚动条UI [英] Weird scrollbar UI in hosted WPF composite control
问题描述
我的窗口应用程序主机AvalonEdit(有问题的复合WPF控件)在其形式之一,以满足其文本编辑要求。这里是我使用的代码:
My windows forms application hosts AvalonEdit (the composite WPF control in question) in one of its forms to cater to its text editing requirements. Here's the code I use:
WPFHost = gcnew ElementHost();
TextField = gcnew AvalonEdit::TextEditor();
WPFHost->Dock = DockStyle::Fill;
WPFHost->Child = TextField;
TextField->Options->AllowScrollBelowDocument = false;
TextField->Options->EnableEmailHyperlinks = false;
TextField->Options->EnableHyperlinks = true;
TextField->Options->RequireControlModifierForHyperlinkClick = true;
TextField->ShowLineNumbers = true;
ContainerControl->Controls->Add(WPFHost); // the container is a panel
代码编译并执行得很好,除了滚动条 - http://dl.dropbox.com/u/2584752/avalonEditBug.png 。右键点击栏左侧会产生一个ArgumentOutOfRange异常。
The code compiles and executes fine, except for the scrollbars - http://dl.dropbox.com/u/2584752/avalonEditBug.png . Right clicking on what's left of the bar raises an ArgumentOutOfRange exception.
奇怪的是,当我尝试在新创建的示例中托管控件时,我无法重现该问题项目。 'mI使用最新版本的文本编辑器并安装了所有必需的程序集。
Strangely, I wasn't able to reproduce the issue when I tried hosting the control in a newly created sample project. 'mI using the latest build of the text editor and have all the requisite assemblies installed.
编辑:在用户控件中包含编辑器也没有帮助。
Wrapping the editor in a usercontrol doesn't help either.
推荐答案
我已经为这个线程中提到的问题实现了一个解决方法[使用WinForms ScrollBar同步WPF ScrollViewer ]。
I've implemented a workaround for the issue as mentioned in this thread [ Synchronizing a WPF ScrollViewer with a WinForms ScrollBar ].
这篇关于在托管的WPF复合控件中的奇怪的滚动条UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!