DLToolkit.Forms.Controls icon indicating copy to clipboard operation
DLToolkit.Forms.Controls copied to clipboard

Crashing with many conversion errors

Open lunarpulse opened this issue 6 years ago • 1 comments

Platform

  • Android

Reproduction

  • start SampleApp as it is, no modifications
  • Advanced Grouping: No FlowGroupShortName on the left displayed
  • scroll randomly and click items while scrolling

Error messages

17 lines of error message in a sec and crashes app

[0:] ForceReload
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'
[0:] Binding: Xamarin.Forms.Internals.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell] can not be converted to type 'System.String'

My thought

  • FlowGroupShortNameBinding has some conversion problem with Grouping<string, SimpleItem> converting to String.
  • I guess implicit conversion may need in there. this seem to be also intrinsic bug from Xamarin.

lunarpulse avatar Oct 09 '18 14:10 lunarpulse

It's not the FlowList's binding it's Xamarin Forms binding. Sometimes the Xamarin Forms Bindings don't convert value to string automatically and there is need a converter. Here is my converter :

image

`public class ToStringConverter : AbstractConverter { public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is string) return value;

        var coll = value as IEnumerable;
        if (coll != null)
        {
            string res = null;
            foreach (var elm in coll)
            {
                if (elm == null)
                    continue;

                res += (res == null ? "" : ", ") + elm.ToString();
            }
            return res;
        }
        else
        {
            return value?.ToString();
        }
    }
}`

vlkam avatar Nov 12 '18 10:11 vlkam