我正在尝试在我正在构建的 WPF 应用程序中使用来自 SharpDevelop 4.0 项目的 ICSharpCode.AvalonEdit.TextEditor 控件,但我似乎无法让它工作。
我从 svn://svnmirror.sharpdevelop.net/sharpdevelop/trunk/SharpDevelop/src/Libraries/AvalonEdit 中查看了版本为 4304 的源代码副本。然后,我使用 Visual Studio 2008 SP1 构建了项目,成功,没有错误。
然后我创建了一个空白的新 WPF 项目,将构建 DLL 添加到工具箱并将 TextEditor 控件放到默认的空窗口中,如下所示:
<Window x:Class="AvalonEditTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
Title="Window1" Height="300" Width="300" >
<Grid x:Name="LayoutRoot">
<avalonedit:TextEditor Name="textEditor" />
</Grid>
</Window>
但是,当我运行该项目时,出现的表单完全是空白的。没有插入符,鼠标光标保持默认指针,窗口不响应按键。
我是不是遗漏了什么,或者 AvalonEdit 只是有点坏了?
[编辑:我开始认为这可能与我的特定设置有关。我正在运行 64 位 Windows 7 RC。这可能与它有关吗?我试过只为 x86 构建它,没有任何区别。]
最佳答案
你确定你的命名空间声明是正确的吗?
你可以尝试这样的事情:
<Window x:Class="Editor.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300"
xmlns:e="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit">
<Grid>
<e:TextEditor x:Name="Editor" WordWrap="True" Height="200">
</e:TextEditor>
</Grid>
</Window>
我能够毫无问题地使用它。
关于c# - 在 .Net 3.5 上使用 ICSharpCode.AvalonEdit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1020447/