Microsoft .NET/WPF
[WPF] '_' 문자가 출력되지 않는 경우! (Underline, Underscore)
전자기린
2019. 7. 3. 19:25
보통 Element에 Text형식으로 문자가 들어가게 되면 문제가 안 생기지만
Content형식으로 문자를 넣게 되면 '_' 문자가 정상적으로 출력되지 않는 경우가 있습니다.
그런 경우 '_'문자가 accessKey로 분류되어 처리되었을 확률이 높습니다.
이런 경우 '_' 문자를 "__"문자처럼 '_'를 하나 더 붙여주면 해결됩니다.
<Window x:Class="WPF_Underscore.MainWindow"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="WPF_Underscore" Height="300" Width="300">
<Button
Width="100" Height="100"
Content="_TEST __TEST"/>
</Window>
_TEST 문자열은 accessKey로 분류되어 TEST로 출력되고 두번째 __TEST는 원하는 결과값인 _TEST로 정상적으로 출력됨.