Wpf: XAML won't render left curly bracket in button content

Created on 14 May 2020  路  3Comments  路  Source: dotnet/wpf

  • .NET Core Version: 3.1.202
  • Windows version: 10.0.18363
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? Yes, filed a bug report, but it was closed and redirected here.

    Problem description:

    XAML designer won鈥檛 show left curly bracket if it鈥檚 defined with its decimal reference.

    Actual behavior:

image

Building gives the following build error:

MC3074
The tag '' does not exist in XML namespace https://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 13 Position 17.

Expected behavior:

image

Minimal repro:

<Window x:Class="Accolade_xaml_test.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"
        xmlns:local="clr-namespace:Accolade_xaml_test"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <WrapPanel>
        <Button Content="&#120;" FontSize="40" Width="40"/>
        <Button Content="&#121;" FontSize="40" Width="40"/>
        <Button Content="&#122;" FontSize="40" Width="40"/>
        <Button Content="&#123;" FontSize="40" Width="40"/> <!-- This should show left curly bracket { -->
        <Button Content="&#124;" FontSize="40" Width="40"/>
        <Button Content="&#125;" FontSize="40" Width="40"/>
        <Button Content="&#126;" FontSize="40" Width="40"/>
    </WrapPanel>
</Window>

Most helpful comment

Not rendering left curly bracket is by design and documented in several places, for example here. Reason is that the curly bracket character has special meaning and is used for markup extensions. You have to use {} as escape sequence.

All 3 comments

On a similar note, it won't show low line when followed by line feed:

image

        <Button Content="&#95;" FontSize="40" Width="40"/>
        <Button Content="&#95;&#10;" FontSize="40" Width="40"/> <!-- This should show low line _ -->
        <Button Content="&#96;" FontSize="40" Width="40"/>
        <Button Content="&#96;&#10;" FontSize="40" Width="40"/>

Not rendering left curly bracket is by design and documented in several places, for example here. Reason is that the curly bracket character has special meaning and is used for markup extensions. You have to use {} as escape sequence.

Thanks @weltkante for the follow up.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stevenbrix picture stevenbrix  路  3Comments

Pzixel picture Pzixel  路  3Comments

Normandy picture Normandy  路  3Comments

imanushin picture imanushin  路  3Comments

dotMorten picture dotMorten  路  4Comments