我试图在我正在构建的SharpDevelop应用程序中使用WPF4.0项目中的ICSharpCode.AvalonEdit.TextEditor控件,但似乎无法使其工作。
我从4304版本的svn://svnmirror.sharpdevelop.net/sharpdevelop/trunk/SharpDevelop/src/Libraries/AvalonEdit上签出了源代码的副本。然后,我使用Visual Studio2008 SP1构建了这个项目,它成功了,没有出现错误。
然后,我创建了一个空白的新WPF项目,将build 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位Windows7RC。这会不会与此有关?我试着只为x86构建它,没有什么不同。
发布于 2009-07-12 14:06:33
您确定您的命名空间声明正确吗?
您可以尝试如下所示:
<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>我能够让它正常工作,没有任何问题。
发布于 2009-07-20 23:52:50
AvalonEdit TextEditor只是TextDocument模型的一个视图。问题是新的AvalonEdit实例没有连接到任何模型实例,所以没有任何东西可编辑。
statictype中的代码之所以有效,是因为他使用的不是<avalonedit:TextEditor/>,而是<avalonedit:TextEditor></avalonedit:TextEditor>。这将为Text属性分配一个空字符串,这会导致编辑器隐式创建一个新文档。
但这与最近的AvalonEdit版本不再相关,编辑器现在将始终创建一个新的TextDocument。
发布于 2009-07-30 17:08:10
对于最新的版本,这对我来说是有效的
<DockPanel LastChildFill="True">
<avalonedit:TextEditor
HorizontalAlignment="Stretch"
Name="textEditor1"
VerticalAlignment="Stretch" />
</DockPanel>https://stackoverflow.com/questions/1020447
复制相似问题