xamarin/Xamarin.Forms

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

Aberta

#5.919 aberto em 15 de abr. de 2019

 (3 comentários) (0 reação) (1 responsável)C# (1.926 forks)batch import
a/binding ⛓e/3 :clock3:help wantedinactivet/bug :bug:up-for-grabs

Métricas do repositório

Stars
 (5.644 estrelas)
Métricas de merge de PR
 (Métricas PR pendentes)

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

Guia do colaborador