Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Picker - Custom Control Property pass through - ItemDisplayBinding

$
0
0

Hello,

I'm new to Xamarin - I hope that's not a silly question ;)

I want to have a custom Control with a picker so I can reuse it.
So when I call the custom control everything works like a charm but I can't pass through the ItemDisplayBinding.

Call:
<controls:PickerWithSearch x:Name="pickerWithSearch" **ItemDisplayBinding="{Binding Adresse.Name1}"** ItemSource="{Binding VertreterListe}" Title="Vertreter auswählen"/>

xaml PickerWithSearch:

xaml.cs PickerWithSearch
`
public partial class PickerWithSearch
{
public static readonly BindableProperty TitleProperty = BindableProperty.Create(
"Title",
typeof(string),
typeof(PickerWithSearch),
string.Empty);

        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        public static readonly BindableProperty ItemSourceProperty = BindableProperty.Create(
            "ItemSource",
            typeof(IEnumerable),
            typeof(PickerWithSearch),
            null);

        public IEnumerable ItemSource
        {
            get { return (IEnumerable)GetValue(ItemSourceProperty); }
            set { SetValue(ItemSourceProperty, value); }
        }

        public static readonly BindableProperty ItemDisplayBindingProperty = BindableProperty.Create(
            "ItemDisplayBinding",
            typeof(BindingBase),
            typeof(PickerWithSearch),
            null);

        public BindingBase ItemDisplayBinding
        {
            get { return (BindingBase)GetValue(ItemDisplayBindingProperty); }
            set { SetValue(ItemDisplayBindingProperty, value); }
        }


        public PickerWithSearch()
        {
            InitializeComponent();
        }
    }

`
ItemSource and Title are working. Maybe the BindingBase is wrong? I don't know which Type ItemDisplayBinding need.

I hope someone can help :)


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>