WPF에서 Xaml 파일에 주석을 추가하는 방법은 무엇입니까?
온라인에서 찾은대로이 구문을 사용했지만 오류가 발생합니다.
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<!-- Cool comment -->
xmlns:System="clr-namespace:System;assembly=mscorlib"
'이름은'< '문자, 16 진수 값 0x3C로 시작할 수 없습니다. 4 행, 위치 5 ' XML이 유효하지 않습니다.
이러한 XAML 네임 스페이스 선언이 컨트롤의 부모 태그에 있다고 가정합니까? 다른 태그 안에 주석을 넣을 수 없습니다. 그 외에는 사용중인 구문이 정확합니다.
<UserControl xmlns="...">
<!-- Here's a valid comment. Notice it's outside the <UserControl> tag's braces -->
[..snip..]
</UserControl>
Laurent Bugnion의 멋진 솔루션을 찾았습니다. 다음과 같이 보일 수 있습니다.
<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>
링크 : http://blog.galasoft.ch/posts/2010/02/quick-tip-commenting-out-properties-in-xaml/
링크의 주석 작성자가 강조 표시 대신 무시 접두사에 추가 문자를 제공했습니다.
mc:Ignorable=”ØignoreØ”
xml 태그 안에 주석을 삽입 할 수 없습니다.
나쁜
<Window xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<!-- Cool comment -->
xmlns:System="clr-namespace:System;assembly=mscorlib">
좋은
<Window xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib">
<!-- Cool comment -->
팁 :
Visual Studio에서 텍스트에 주석을 달려면 주석을 달 텍스트를 강조 표시 한 다음 Ctrl + K 다음에 Ctrl + C를 사용 합니다. 주석을 제거하려면 Ctrl + K 다음에 Ctrl + U를 사용할 수 있습니다 .
이 내용을 배우는 사람에게는 주석이 더 중요하므로 단일 속성 주석 에 대한 Xak Tacit의 아이디어
(User500099의 링크 )를 참고하여 XAML 코드 블록의 맨 위에 다음을 추가하십시오.
<!--Comments Allowed With Markup Compatibility (mc) In XAML!
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ØignoreØ="http://www.galasoft.ch/ignore"
mc:Ignorable="ØignoreØ"
Usage in property:
ØignoreØ:AttributeToIgnore="Text Of AttributeToIgnore"-->
그런 다음 코드 블록에서
<Application FooApp:Class="Foo.App"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ØignoreØ="http://www.galasoft.ch/ignore"
mc:Ignorable="ØignoreØ"
...
AttributeNotToIgnore="TextNotToIgnore"
...
...
ØignoreØ:IgnoreThisAttribute="IgnoreThatText"
...
>
</Application>
UWP XAML 태그 내에 주석을 넣을 수 없습니다. 귀하의 구문이 맞습니다.
할 것:
<xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib"/>
<!-- Cool comment -->
하지 말아야 할 것 :
<xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<!-- Cool comment -->
xmlns:System="clr-namespace:System;assembly=mscorlib"/>
참고 URL : https://stackoverflow.com/questions/7921672/how-to-add-comments-into-a-xaml-file-in-wpf
'Program Tip' 카테고리의 다른 글
조인 업데이트를위한 MySQL 구문 (0) | 2020.10.26 |
---|---|
이전 + n 미터에서 새로운 경도, 위도 계산 (0) | 2020.10.26 |
접두사를 포함하는 knockoutjs로 id 속성 설정 (0) | 2020.10.26 |
Python의 튜플 목록에서 최대 값 찾기 (0) | 2020.10.26 |
ID 목록에서 Entity Framework의 여러 행 업데이트 (0) | 2020.10.26 |