mc:Ignorable 特性mc:Ignorable Attribute

指定在标记文件中遇到哪些 XML 命名空间前缀可能会被 XAMLXAML 处理器忽略。Specifies which XML namespace prefixes encountered in a markup file may be ignored by a XAMLXAML processor. mc:Ignorable 特性支持用于自定义命名空间映射和 XAMLXAML 版本控制的标记兼容性。The mc:Ignorable attribute supports markup compatibility both for custom namespace mapping and for XAMLXAML versioning.

XAML 特性用法(单前缀)XAML Attribute Usage (Single Prefix)

<object  
  xmlns:ignorablePrefix="ignorableUri"  
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
  mc:Ignorable="ignorablePrefix"...>  
    <ignorablePrefix1:ThisElementCanBeIgnored/>  
</object>  

XAML 特性用法(两个前缀)XAML Attribute Usage (Two Prefixes)

<object  
  xmlns:ignorablePrefix1="ignorableUri"  
  xmlns:ignorablePrefix2="ignorableUri2"  
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
  mc:Ignorable="ignorablePrefix1 ignorablePrefix2"...>  
    <ignorablePrefix1:ThisElementCanBeIgnored/>  
</object>  

XAML 值XAML Values

ignorablePrefix、ignorablePrefix1 等。ignorablePrefix, ignorablePrefix1, etc. 根据 XML 1.0 规范的任何有效的前缀字符串。Any valid prefix string, per the XML 1.0 specification.
ignorableUriignorableUri 根据 XML 1.0 规范指定命名空间的任何有效 URI。Any valid URI for designating a namespace, per the XML 1.0 specification.
ThisElementCanBeIgnoredThisElementCanBeIgnored 如果无法解析基础类型,则 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) 处理器实现可忽略的元素。An element that can be ignored by 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) processor implementations, if the underlying type cannot be resolved.

备注Remarks

XAMLXAML 兼容命名空间 http://schemas.openxmlformats.org/markup-compatibility/2006时,建议使用 mc XML 命名空间前缀。The mc XML namespace prefix is the recommended prefix convention to use when mapping the XAMLXAML compatibility namespace http://schemas.openxmlformats.org/markup-compatibility/2006.

元素名称的前缀部分标识为 mc:IgnorableXAMLXAML 处理器处理时不会引发错误的元素或属性。Elements or attributes where the prefix portion of the element name are identified as mc:Ignorable will not raise errors when processed by a XAMLXAML processor. 如果该特性未能解析为基础类型或编程构造,则将忽略该元素。If that attribute could not be resolved to an underlying type or programming construct, then that element is ignored. 但请注意,如果忽略元素,则忽略的元素可能仍会生成其他元素要求的分析错误。Note however that ignored elements might still generate additional parsing errors for additional element requirements that are side effects of that element not being processed. 例如,特定的元素内容模型可能只需要一个子元素,但如果指定的子元素位于 mc:Ignorable 前缀中,并且指定的子元素未能解析为类型,则 XAMLXAML 处理器可能会引发错误。For instance, a particular element content model might require exactly one child element, but if the specified child element was in an mc:Ignorable prefix, and the specified child element could not be resolved to a type, then the XAMLXAML processor might raise an error.

mc:Ignorable 仅适用于标识符字符串的命名空间映射。mc:Ignorable only applies to namespace mappings to identifier strings. mc:Ignorable 不适用于将命名空间映射到程序集,这些程序集指定 CLR 命名空间和程序集(或作为程序集的当前可执行文件的默认值)。mc:Ignorable does not apply to namespace mappings into assemblies, which specify a CLR namespace and an assembly (or default to the current executable as the assembly).

如果要实现 XAMLXAML 处理器,则处理器实现对于由标识为 mc:Ignorable的前缀限定的任何元素或属性,都不得引发分析或处理错误。If you are implementing a XAMLXAML processor, your processor implementation must not raise parsing or processing errors on type resolution for any element or attribute that is qualified by a prefix that is identified as mc:Ignorable. 但您的处理器实现仍可能引发异常,这些异常是无法加载或处理元素的辅助结果,如前面给出的一个子元素示例。But your processor implementation can still raise exceptions that are a secondary result of an element failing to load or be processed, such as the one-child element example given earlier.

默认情况下,XAMLXAML 处理器将忽略忽略元素中的内容。By default, a XAMLXAML processor will ignore content within an ignored element. 但是,您可以指定一个附加属性mc: ProcessContent 特性,以要求在下一个可用的父元素中继续处理被忽略元素内的内容。However, you can specify an additional attribute, mc:ProcessContent Attribute, to require continued processing of content within an ignored element by the next available parent element.

可以使用一个或多个空白字符作为分隔符,在属性中指定多个前缀,例如: mc:Ignorable="ignore1 ignore2"Multiple prefixes can be specified in the attribute, using one or more white-space characters as the separator, for example: mc:Ignorable="ignore1 ignore2".

http://schemas.openxmlformats.org/markup-compatibility/2006 命名空间定义 SDK 的此区域中未记录的其他元素和特性。The http://schemas.openxmlformats.org/markup-compatibility/2006 namespace defines other elements and attributes that are not documented within this area of the SDK. 有关详细信息,请参阅XML 标记兼容性规范For more information, see XML Markup Compatibility Specification.

请参阅See also