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

ListView, TextCell question about itemsource

$
0
0

Is there a way to dynamically set TextCell color based on each itemsource value?

        VehicleList.ItemsSource = vehicleList;
        VehicleList.ItemTemplate = new DataTemplate (typeof(TextCell)) { 
            Values = {
                { TextCell.TextColorProperty, TextColor(???)} // ie vehicleList[index].status
            },
            Bindings = {
                { TextCell.TextProperty, new Binding("VIN") }
            }};
    }

    private Xamarin.Forms.Color TextColor (string status) { 

        switch (status) {
        case "Loading":
        case "Delivering":
            return Color.Red;
        case "Loaded":
        case "Delivered":
            return Color.Green;
        default:
            return Color.Black;
        }

    }

Viewing all articles
Browse latest Browse all 58056

Trending Articles



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