Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Can not convert EventColor to type 'Xamarin.Forms.Color'

BuckPrivateBuckPrivate USUniversity ✭✭

I'm trying to change TextColorProperty on a TextCell using a DataTemplate. in my model I have public Xamarin.Forms.Color EventColor to use in the datatemplate. For some reason its telling me it can't convert EventColor(Xamarin.Forms.Color) to 'Xamarin.Forms.Color'. They should be the same thing. Why is it confused about using the EventColor from my model?

my EventColor in Classes looks like this:

EventColor = R=1, G=0, B=0, A=1, Hue=1, Saturation=1, Luminosity=0.5

ListView and DataTemplate

classList = new ListView()
            {
                ItemsSource = viewModelStart.Classes,
            };

            classList.ItemTemplate = new DataTemplate(typeof(TextCell));
            classList.ItemTemplate.SetBinding(TextCell.TextProperty, "class_name");
            classList.ItemTemplate.SetBinding(TextCell.DetailProperty, "start_time");
            classList.ItemTemplate.SetValue(TextCell.TextColorProperty, "EventColor");

Answers

  • BuckPrivateBuckPrivate USUniversity ✭✭

    I figured it out. I had to change SetValue to SetBinding. I think this is because I'm using EventColor from my model and not specifying an actual color value to be used in the DateTemplate. Hope this helps someone down the road.

Sign In or Register to comment.