xamarin/Xamarin.Forms

[Bug] Data binding an array item of type enum is incorrect

Open

#5,919 opened on Apr 15, 2019

 (3 comments) (0 reactions) (1 assignee)C# (1,926 forks)batch import
a/binding ⛓e/3 :clock3:help wantedinactivet/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

When binding to a particular index in an array, the result is different that if it was a property.

Steps to Reproduce

Given an enum:

public enum Player {
    Nobody,
    X,
    O
}

And 2 properties:

public Player[] Board { get; }
public Player CurrentPlayer { get; set; }

If I add a databinding:

Text="{Binding CurrentPlayer}"

The value will either be "X", "O" or "Nobody". If I bind to an array item:

Text="{Binding Board[1]}"

The value will be "0", "1", or "2".

Expected Behavior

The array data binding uses .ToString().

Actual Behavior

The array binding uses some integer representation.

Basic Information

  • Version with issue: 3.6.0.293080
  • Last known good version: (not sure)
  • IDE: VS 2019
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

Contributor guide