在 .Net 3.5 上使用 ICSharpCode.AvalonEdit?

发布于 2024-07-24 23:37:51 字数 1010 浏览 10 评论 0原文

我正在尝试在我正在构建的 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 构建它,但没有什么区别。]

I'm trying to use the ICSharpCode.AvalonEdit.TextEditor control from the SharpDevelop 4.0 project in a WPF app that I'm building, but I can't seem to get it to work.

I checked out a copy of the source code from svn://svnmirror.sharpdevelop.net/sharpdevelop/trunk/SharpDevelop/src/Libraries/AvalonEdit at revision 4304. Then, I built the project using Visual Studio 2008 SP1, which succeeded without errors.

I then created a blank new WPF project, added the build DLL to the toolbox and dropped the TextEditor control onto the default empty window, like so:

<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>

However, when I run the project, the form comes up completely blank. No caret, the mouse cursor stays the default pointer, and the window does not respond to keypresses.

Am I missing something, or is AvalonEdit just a little broken?

[EDIT: I'm starting to think it might be related to my specific setup. I'm running the 64-bit Windows 7 RC. Might that have something to do with it? I've tried building it for x86 only, made no difference.]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

黑白记忆 2024-07-31 23:37:51

您确定您的命名空间声明正确吗?

你可以尝试这样的事情:

<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>

我能够让它正常工作,没有任何问题。

Are you sure your namespace declaration is correct?

You can try something like this:

<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>

I was able to get it to work without any issues.

少女情怀诗 2024-07-31 23:37:51

AvalonEdit TextEditor 只是 TextDocument 模型的一个视图。
问题是新的 AvalonEdit 实例没有开始连接到任何模型实例,因此没有任何内容可以编辑。

statictype 中的代码起作用的原因是他没有使用 ,而是使用 。 这将为 Text 属性分配一个空字符串,从而导致编辑器隐式创建一个新文档。

但这与最近的 AvalonEdit 版本不再相关,编辑器现在将始终创建一个新的 TextDocument。

The AvalonEdit TextEditor is just a view for a TextDocument model.
The problem was that a new AvalonEdit instance didn't start connected to any model instance, so there wasn't anything to edit.

The reason the code from statictype worked was that he didn't use <avalonedit:TextEditor/>, but <avalonedit:TextEditor></avalonedit:TextEditor>. This will assign an empty string to the Text property, which caused the editor to implicitly create a new document.

But this isn't relevant with recent AvalonEdit versions anymore, the editor will now always create a new TextDocument.

忱杏 2024-07-31 23:37:51

这对我来说适用于最新版本

<DockPanel LastChildFill="True">
    <avalonedit:TextEditor 
        HorizontalAlignment="Stretch"
        Name="textEditor1" 
        VerticalAlignment="Stretch" />
</DockPanel>

This works for me with the latest build

<DockPanel LastChildFill="True">
    <avalonedit:TextEditor 
        HorizontalAlignment="Stretch"
        Name="textEditor1" 
        VerticalAlignment="Stretch" />
</DockPanel>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文