【问题标题】:Can mc:ignorable be used to create a XAML comment tag?可以使用 mc:ignorable 创建 XAML 注释标记吗?
【发布时间】:2022-01-17 09:13:31
【问题描述】:

我想创建一个评论标签以在我的 XAML 中使用,以便我可以评论它。 (为什么没有现成的内置方法来做到这一点让我感到困惑。)

下面的代码sn-p编译失败,报错:

*Error      'mc:Ignorable' is a duplicate attribute name. Line 9, position 7.   TriCoordinate Math*         

任何帮助将不胜感激。


    <Page x:Class="TriCoordinate_Math.Views.GraphingPage"
          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:Comment="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          Style="{StaticResource PageStyle}"
          mc:Ignorable="Comment"
          mc:Ignorable="d">

【问题讨论】:

    标签: xaml uwp-xaml


    【解决方案1】:

    在另一个问题中找到了这个:

    效果很好。比必须完全放在标签之外的愚蠢默认机制要好得多。 (这在很大程度上是无用的,而且通常非常令人困惑)

    <UserControl xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 xmlns:comment="Tag to add comments"
                 mc:Ignorable="d comment" d:DesignHeight="300" d:DesignWidth="300">
        <Grid>
            <Button Width="100"
                    comment:Width="example comment on Width, will be ignored......">
            </Button>
        </Grid>
    </UserControl>
    

    这个方法的这个实现编译正确,正是我想要的。

    <Page x:Class="TriCoordinate_Math.Views.GraphingPage"
          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:Comment="Tag used for commenting"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          Style="{StaticResource PageStyle}"
          mc:Ignorable="d Comment">
    
        <Grid x:Name="ContentArea"
              Margin="0"
              Loaded="ContentArea_Loaded">
            <Grid Background="{ThemeResource CustomAcrylicGraphingBackgroundBrush}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="40" Comment:Row0="application header"/>
                    <RowDefinition Height="1*" Comment:Row1="application body"/>
                    <RowDefinition Height="40" Comment:Row2="application footer"/>
                </Grid.RowDefinitions>
    

    【讨论】:

      猜你喜欢
      • 2022-01-15
      • 2017-07-07
      • 1970-01-01
      • 2013-02-18
      • 2011-01-25
      • 2011-08-24
      • 2016-02-03
      • 2020-11-19
      • 2010-09-19
      相关资源
      最近更新 更多