coolc0ders / Accordion-View-Xamarin.Forms

Simple Accordion in Xamarin.Forms
18 stars 8 forks source link

Binding Accordion Title #2

Open HamidBaghernia opened 4 years ago

HamidBaghernia commented 4 years ago

Hi, how is it possible to bind the title of the accordion to the items source of the collectionView, please?

It says "Todo" all of the time and binding creates an error of No property, bindable property, or event found for 'Title', or mismatching type between value and property.

DamienDoumer commented 4 years ago

Hi, thanks for your interest in this sample. If I understand well you are willing to bind the title of the accordion view to the collection view's itens source ?. The title is a string and the collection view's item source is a list of items this is not possible in Xamarin Forms that is why you are getting the error message: " mismatching type between value and property."

JStammen commented 4 years ago

Might be late but the issue is the following:

public static readonly BindableProperty TitleBindableProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(Accordion), default(string));
        public string Title
        {
            get => (string)GetValue(TitleBindableProperty);
            set => SetValue(TitleBindableProperty, value);
        }

Due to xamarins naming convention a BindableProperty is always Propertyname suffixed with Property as followed:

public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(Accordion), default(string));
        public string Title
        {
            get => (string)GetValue(TitleProperty);
            set => SetValue(TitleProperty, value);
        }
MahmudX commented 2 years ago

@JStammen thanks man, you gave the solid answer.