xamarin/Xamarin.Forms

[Bug] Binding to Dictionary is broken

开放

#8,377 创建于 2019年11月5日

 (6 条评论) (0 个反应) (1 位负责人)C# (1,926 个派生)batch import
4.3.0a/binding ⛓e/5 :clock5:help wantedi/regressioninactivet/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Description

When updating to Xamarin.Forms 4.3 bindings to Dictionaries no longer work. The binding is on a Label where i show a value from a dictionary. The Value is converted to string with a custom IValueConverter. Before the update on Xamarin.Forms 4.2 everything worked perfectly. I already tried alot but nothing worked.

That's the binding in Codebehind:

value.SetBinding(Label.TextProperty, new Binding(string.Format("InputRegisters[{0}]", parameterOrSubemnu.Parameter.ModbusRegisterItem.RegisterAddress),
source: CurrentDevice.DataStore));

The dictionary: InputRegisters = new ConcurrentDictionary<ushort,ushort>();

Steps to Reproduce

  1. Create Dictionary of short, double or int.
  2. bind to dict.

I already tried many different ways of discribing the Binding, but nothing worked. Also tested it with different types like int or double.

Expected Behavior

Binding to Dictionary is working.

Actual Behavior

I get: [0:] Binding: can not be converted to type 'System.Double'

Basic Information

  • Version with issue: Xamarin.Forms 4.3.0.947036
  • Last known good version: Xamarin.Forms 4.2...
  • IDE: Visual Studio 19 Windows
  • Platform Target Frameworks:
    • iOS: iOS SDK 13
    • Android: 9

Screenshots

grafik

贡献者指南