使用 Blend 自定义 XmlnsDefinition

发布于 2024-08-02 13:33:11 字数 643 浏览 4 评论 0原文

在我的项目中,我有一个定义一组 WPF 控件的程序集。我希望能够在不显式引用 XAML 代码中的程序集的情况下使用它们。这就是我使用自定义 XmlnsDefinition 的原因:

[assembly: XmlnsDefinition(
    "http://schemas.microsoft.com/winfx/2006/xaml/presentation",
    "MyProject.Common.WpfLibrary.Markup")]
[assembly: XmlnsDefinition(
    "http://schemas.microsoft.com/winfx/2007/xaml/presentation",
    "MyProject.Common.WpfLibrary.Markup")]
[assembly: XmlnsDefinition(
    "http://schemas.microsoft.com/winfx/2008/xaml/presentation",
    "MyProject.Common.WpfLibrary.Markup")]

它在 VS2008 中就像一个魅力。我可以直接使用标记命名空间中定义的控件。然而 Blend 似乎不喜欢它,并且在我尝试使用控件的任何地方都会给出“无效的 XAML”错误。

你有解决方法吗?

In my project, I have an assembly that defines a set of WPF controls. I want to be able to use them without referencing explicitly the assembly in the XAML code. That's why I'm using custom XmlnsDefinition:

[assembly: XmlnsDefinition(
    "http://schemas.microsoft.com/winfx/2006/xaml/presentation",
    "MyProject.Common.WpfLibrary.Markup")]
[assembly: XmlnsDefinition(
    "http://schemas.microsoft.com/winfx/2007/xaml/presentation",
    "MyProject.Common.WpfLibrary.Markup")]
[assembly: XmlnsDefinition(
    "http://schemas.microsoft.com/winfx/2008/xaml/presentation",
    "MyProject.Common.WpfLibrary.Markup")]

It works like a charm in VS2008. I can use controls defined in the Markup namespace directly. However Blend doesn't seem to like it, and give my an "Invalid XAML" error wherever I try to use a control.

Do you have a workaround ?

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

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

发布评论

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

评论(1

憧憬巴黎街头的黎明 2024-08-09 13:33:11

对于程序集中的每个 CLR 命名空间,您应该仅使用一次 XmlnsDefinitionAttribute。使用 XmlnsCompatibleWithAttribute 进行第二次和第三次分配。

You should use XmlnsDefinitionAttribute only one time for each CLR-Namespace in an assembly. Use XmlnsCompatibleWithAttribute for the 2nd and 3rd assignment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文