xamarin/Xamarin.Forms

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

Aperta

#5919 aperta il 15 apr 2019

 (3 commenti) (0 reazioni) (1 assegnatario)C# (1926 fork)batch import
a/binding ⛓e/3 :clock3:help wantedinactivet/bug :bug:up-for-grabs

Metriche repository

Star
 (5644 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor