ItemsSource bindable property

qweerqweer Member ✭✭

Hello, i'm trying to make ContentView with 2 items and I need to send ItemsSource as bindable property. I tried like this, but it didn't work.

Xaml:

        <Grid>
            <Label
                Text="Text"
                TextColor="Black"
                VerticalOptions="CenterAndExpand" />

            <controls:ExtendedPicker
                Title="Title"
                HorizontalOptions="End"
                ItemDisplayBinding="{Binding PickerItemDisplayBinding, Source={x:Reference This}}"
                ItemsSource="{Binding PickerItemsSource, Source={x:Reference This}}"
                SelectedIndex="{Binding PickerSelectedIndex, Source={x:Reference This}}" />
        </Grid>

Xaml.cs:

    public static readonly BindableProperty PickerItemsSourceProperty = BindableProperty.Create(
        "PickerItemsSource",
        typeof(IList),
        typeof(DetailedPicker));

    public static readonly BindableProperty PickerSelectedIndexProperty = BindableProperty.Create(
        "PickerSelectedIndex",
        typeof(int),
        typeof(DetailedPicker));

    public static readonly BindableProperty PickerItemDisplayBindingProperty = BindableProperty.Create(
        "PickerItemDisplayBinding",
        typeof(BindingBase),
        typeof(DetailedPicker));

    public IList PickerItemsSource
    {
        get => (IList) GetValue(PickerItemsSourceProperty);
        set => SetValue(PickerItemsSourceProperty, value);
    }


    public int PickerSelectedIndex
    {
        get => (int) GetValue(PickerSelectedIndexProperty);
        set => SetValue(PickerSelectedIndexProperty, value);
    }

    public BindingBase PickerItemDisplayBinding
    {
        get => (BindingBase) GetValue(PickerItemDisplayBindingProperty);
        set => SetValue(PickerItemDisplayBindingProperty, value);
    }

How can I bind ItemsSource as BindableProperty?

Answers

  • Hi, did you manage to figure this out?
    I'm trying to achieve exactly the same thing but I'm stuck...

Sign In or Register to comment.