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

ListView with CustomCell Bindable Property

$
0
0

Hi,

I have a ListView with Custom Cell in it.

The custom Cell looks like this:

`
public class CustomCell : ViewCell
{

    private readonly string[] _pickerFields = new string[] {"1", "2", "3"};

    public CustomCell()
    {
        var label1 = new Label
        {
            Text = "",              
        };

        label1.SetBinding(Label.TextProperty, new Binding("."));

        var Picker = new BindablePicker()
        {
            Title = "status",
            HorizontalOptions = LayoutOptions.StartAndExpand,
            ItemsSource = _pickerFields,
            SelectedIndex = 0
        };

        View = new StackLayout
        {
            Orientation = StackOrientation.Horizontal,
            HorizontalOptions = LayoutOptions.StartAndExpand,
            Children =
            {
                label1,
                Picker,
                label2,
            }
        };
    }
}

`
Then I call my ListView like this. and for some reason label1 is filled with the "service.TextForList" .

listView.ItemsSource = List.Select(service => service.TextForList);
listView.ItemTemplate= new DataTemplate(typeof(CustomCells.CustomCell));

But how do I set the selected Index for the Picker and the Text for label2?

Thank you


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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