命名空间中不存在 c# WPF AlternateContent [...] [英] c# WPF AlternateContent doesn't exist in the Namespace [...]

查看:28
本文介绍了命名空间中不存在 c# WPF AlternateContent [...]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要仅在设计时使用 XAML 代码.我找到了一个很好的解决方案,可以在这里找到.似乎有些人对 XmlnsDefinitionAttribute 的解析时间有问题,here.

I am facing the need to have XAML Code only in design-time. I have found a nice Solution to this, which can be found here. It seems like there are a few guys having a Problem with the parse-timing of XmlnsDefinitionAttribute which is solved here.

就我而言,问题确实是,我无法编译我的代码,因为在名称空间 xmlns:mc="http://schemas 中找不到 AlternateContent.openxmlformats.org/markup-compatibility/2006".我确实没有找到这个命名空间的任何文档,这看起来很奇怪,行 mc:Ignorable="d" 没有构建失败,这意味着我至少有一个程序集包含上面的命名空间.

In my case the issue is really, that I cannot compile my code, because AlternateContent can't be found in the namespace xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006". I haven't found any documentation to this namespace indeed and it seems strange, that the line mc:Ignorable="d"doesn't fail to build, which means I have at least one assembly containing the above namespace.

这是我的代码:

#if DEBUG
[assembly: XmlnsDefinition("debug-mode", "MyNamespace")]
#endif

<Window x:Class="MyNamespace.SomeWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:debug="debug-mode"
        mc:Ignorable="d"
        ... >
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <mc:AlternateContent>
                    <mc:Choice Requires="debug">
                        <ResourceDictionary Source="pack://application:,,,/Styles;component/Generic.xaml" />
                    </mc:Choice>
                </mc:AlternateContent>
                ...
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    ...
</Window>

我的猜测是,我缺少程序集参考,但我还没有找到为 AlternateContent 指定包含程序集的文档.你对我如何让 这个起作用有什么想法吗?

My guess is, that I'm missing an Assembly-Reference, but I've not yet found a Documentation specifying a containing Assembly for AlternateContent. Do you have any ideas how I might get this to work?

这似乎是一个常见的 VS 问题,可以通过这个 mc:Ignorable="d mc" 解决.这在我的情况下不起作用,因为我需要它来包含设计时的资源,VS-Designer 应该可以使用它:)

It seems like this is a common VS Problem which can be solved by this mc:Ignorable="d mc". This just doesn't work in my case, because I would need this to include Resources at Design-Time, which should be available to the VS-Designer :)

推荐答案

看来这是一个常见的 VS 问题,可以通过这段代码解决

It seems like this is a common VS problem which can be solved by this code

mc:Ignorable="d mc"

这必须添加到视图的根元素.
注意:您的根元素中应该已经有 mc:Ignorable="d",因此您只需将 mc 添加到它.

This must be added to the root element of the view.
Note: that you already should have mc:Ignorable="d" in your root element, so you have to just add the mc to it.

这篇关于命名空间中不存在 c# WPF AlternateContent [...]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆