WPF注釋具體概念詳解
WPF的應(yīng)用中還是需要我們進行相關(guān)的代碼編寫才能實現(xiàn)一些特定的功能。寫過XAML的朋友應(yīng)該都知道:在XAML中可以通過< !--****-->標(biāo)記來實現(xiàn)WPF注釋。但是,利用XAML標(biāo)記兼容性,還提供了其它更加強大的注釋功能。#t#
- < Window
- xmlns="http://schemas.microsoft.com
/winfx/2006/xaml/presentation" - xmlns:mc=http://schemas.openxml
formats.org/markup-compatibility/2006 - xmlns:c="Comment"
- mc:Ignorable="c">
- < Canvas>
- < Button c:Width="100" Height=
"50">Hello< /Button> - < /Canvas>
- < /Window>
看見了Width前面的c前綴嗎?它的作用就是注釋掉Width屬性。是不是感覺比標(biāo)記WPF注釋的方法簡單。而且這個c前面不但可以應(yīng)用在屬性上,也可以直接應(yīng)用在實例上,如下:
- < Window
- xmlns=http://schemas.microsoft.
com/winfx/2006/xaml/presentation- xmlns:mc=http://schemas.openxml
formats.org/markup-compatibility/2006- xmlns:c="Comment"
- mc:Ignorable="c">
- < Canvas>
- < c:Button Width="100" Height=
"50">Hello< /c:Button>- < /Canvas>
- < /Window>
上面的代碼就全部注釋掉了Button實例。當(dāng)然,這種WPF注釋方法不建議在***的發(fā)布XAML文檔中出現(xiàn)。只適合在XAML文檔的開發(fā)過程中使用。