Eri*_*ber 28 xaml attributes comments
这困扰了我一段时间,也许我错过了一些东西.
以下引用了注释属性(expected>)的错误,但是我不能做这样的事情吗?
<Label x:Name="Gaga"
               FontSize="20"
               <!--
               Content="{Binding SomethingThatIsEmptyAtDesignTime"}
                -->
               Content="LookAtMe!"
               />
Eri*_*ber 26
虽然您无法使用基本XAML标记进行注释,但您可以通过导入Open XML标记命名空间来实现所需的结果.
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ignore="http://www.galasoft.ch/ignore"
mc:Ignorable="ignore"
<Label x:Name="Gaga"
       FontSize="20"
       ignore:Content="{Binding SomethingThatIsEmptyAtDesignTime"}
       Content="LookAtMe!"
/>
这篇博文描述了如何做到这一点.
kux*_*kux 20
答案很简单:因为一个<字符是不允许之间<并>(通过XML定义).
下一个问题应该是"如何注释掉XML/XAML属性"
解决方案(例如,在MS Blend/Visual Studio中)是一个mc:Ignorable属性.
<RootElement
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    mc:Ignorable="d" 
    d:DataContext="this is an attribute for design time only"
>
因此,如果要注释掉,只需d:在属性中添加前缀即可
为了更有用,你可以拥有更多作为一个可忽略的前缀:
<RootElement
    xmlns   ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d ="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:rem ="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:TODO ="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:DISABLED ="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:NOTE ="http://schemas.microsoft.com/expression/blend/2008"
    mc:Ignorable="d rem TODO DISABLED NOTE" 
    d:Foo="this is ignored (design time only attribute)"
    rem:Background="this is also ignored (commented out)"
    TODO:Background=" (commented as TODO)"
    DISABLED:Background="this is also ignored (commented as DISABLED)"
>
"令牌" rem TODO DISABLED NOTE只是我的建议,任何其他(有效的xml名称)都是可能的.
任何元素的实际样本:
<TextBox
    DISABLED:Background="#FF000000"  NOTE:Background="temporary disabled"
    Background="#FFFFFF"             TODO:Background="specify an other background"
    TODO:TextBox="complete the textbox"
>
unicode字符的用法:
以下unicode字符列表对xml名称有效:
? ? ? ? ? ? ?
<TextBox
    ?:Background="temporary disabled"
    ?:Background="temporary disabled"
    ?:Background="temporary disabled"
>
用作文档(XML注释)
<RootElement
    ...
    xmlns:doc="http://schemas.microsoft.com/expression/blend/2008"
    mc:Ignorable="... doc ..." 
    <MyControl
        doc.summary="shows my control"
        doc.remarks="any remarks..."
    />
>
| 归档时间: | 
 | 
| 查看次数: | 8438 次 | 
| 最近记录: |