1

我正在尝试为 Silverlight 编译AvalonEdit,但我不知道该怎么做,因为我从未使用过 Silverlight,只有 WPF。

我尝试将此控件添加到我的 Silverlight 应用程序,但 Visual Studio 抱怨该程序集未针对 Silverlight 编译。

我认为这将是在项目设置中的目标平台下选择 Silverlight 的问题。

有任何想法吗?

4

3 回答 3

2

Silverlight and WPF assemblies are not compatible. So any assembly you reference from your Silverlight assembly must also have been compiled as a Silverlight assembly. I'm assuming your reference to "project settings" is your assembly, not the third party assembly.

But, compiling WPF code as Silverlight may be challenging. Silverlight is a functional subset of WPF so the code may use features not available in Silverlight.

于 2011-12-30T08:26:43.720 回答
1

You need to create new project which targets silverlight (File - New Project - Silverlight) and then add all the source code from the AvalonEdit source code into that library.

Edit:

Also note that the control might use classes that are not available in Silverlight. From the codeplex discussion related to this control (from year 2009):

Silverlight does not have the System.Windows.Media.TextFormatting namespace, so you'd have to rewrite a large part of the ICSharpCode.AvalonEdit.Rendering namespace if you want to port AvalonEdit to Silverlight.

于 2011-12-30T08:25:21.043 回答
1

在silverlight 项目中,您不能引用非silverlight dll 或项目。所以在这个项目中,如果有一个必不可少的非silverlight dll来构建这个项目。你不能做这个构建。

如果只有 wfp 支持的一些用法,但 silverlight 不支持,则发现这有所不同。然后排除这些代码或使用 pragma

#if !WPF
//Todo
#endif
于 2011-12-30T08:42:57.983 回答