microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.85k stars 323 forks source link

The TextBlock TextAlignment enumeration contains duplicate entries. #4737

Open johnt-star opened 1 month ago

johnt-star commented 1 month ago

Describe the bug

Not sure if this is a bug or by design, but the TextAlignment enumeration used by TextBlock contains the duplicate entries.

Using Enum.GetValues shows there are 7 entries in total.

There are 2 entries labelled Left and 2 entries Labelled Right.

Screen capture below lists all entries.

Steps to reproduce the bug

See attached code.

Use Enum.GetValues to retrieve and display TextAlignment members.

Expected behavior

Entries should have unique names in order to distinguish between the entry's behavior.

Screenshots

This is the list showing the duplicate names: image

This is a breakpoint in the code showing duplicates. Note that the entry "Right" shows up as "End", but is still duplicated. image

NuGet package version

Windows App SDK 1.6.0: 1.6.240829007

Packaging type

Packaged (MSIX)

Windows version

Windows 10 version 22H2 (19045, 2022 Update)

IDE

Visual Studio 2022

Additional context

MainWindow.xaml <?xml version="1.0" encoding="utf-8"?> <Window x:Class="TextBlockAlignment.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:TextBlockAlignment" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
    <TextBlock Name="TextBlockMain"></TextBlock>
    <ListView Name="ListViewMain"></ListView>
</StackPanel>

MainWindow.xaml.cs public sealed partial class MainWindow : Window { public MainWindow() { this.InitializeComponent();

        DisplayTextAlignment();
    }

    private void DisplayTextAlignment()
    {
        int iIdx;
        int iCount;

        Array arTextAlignment;

        ListViewItem listViewItem;

        // Get array of enums
        arTextAlignment = Enum.GetValues(typeof(TextAlignment));

        iCount = arTextAlignment.Length;

        for (iIdx = 0; iIdx < iCount; ++iIdx)
        {
            listViewItem = new ListViewItem
            {
                Content = arTextAlignment.GetValue(iIdx).ToString(),
            };

            ListViewMain.Items.Add(listViewItem);
        }
    }

Attaching project TextBlockAlignment.zip