假设我们有以下代码:
<Window
x:Class="Consus.Client.UI.Sandbox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
x:Name="RibbonWindow"
Width="800" Height="600"
MinWidth="800" MinHeight="600"
Title="MainWindow">我们希望在MinWidth="800“MinHeight="600"行中添加一个注释,以表示”这是应用程序的最小宽度/高度“。我试过:
<Window
x:Class="Consus.Client.UI.Sandbox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
x:Name="RibbonWindow"
Width="800" Height="600"
MinWidth="800" MinHeight="600" <!--My comment goes here-->
Title="MainWindow">但这引起了一个错误。那我该怎么做呢?
发布于 2010-10-04 01:41:45
不可能以这种方式向属性添加注释。XAML是一种XML方言,因此遵循XML的语法规则,这对此不利。XML注释只能出现在其他标记元素之外(或者更简单地显示在其他XML元素标记之外)。
可以添加的最接近的位置是<Window>元素之前或之后。
<!-- Legal -->
<Window
...
> <!-- Legal -->发布于 2015-06-15 10:30:22
添加名称空间:xmlns:comment="my comment"
mc:Ignorable="comment"提示:如果您已经忽略了像xmlns:d="http://schemas.microsoft.com/expression/blend/2008"这样的名称空间,只需使用空格:mc:Ignorable="a comment"加入这些名称空间
<Window
x:Class="Consus.Client.UI.Sandbox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
x:Name="RibbonWindow"
Width="800" Height="600"
MinWidth="800" comment:MinWidth="Some comment for MinWidth"
MinHeight="600" comment:MinWidth="Some comment for MinHeight"
Title="MainWindow">
...
</Window>https://stackoverflow.com/questions/3852263
复制相似问题