Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The TextBlock TextAlignment enumeration contains duplicate entries. #4737

Open
johnt-star opened this issue Sep 20, 2024 · 0 comments
Open
Assignees

Comments

@johnt-star
Copy link

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

<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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants