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

TableSection change Title color

$
0
0

Hi all!
It's impossible to set color for title in TableSection.
I wrote a renderer for table and try to set color there:

 public class TestTableViewRenderer : Xamarin.Forms.Platform.Android.TableViewRenderer
    {
        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.TableView> e)
        {
            base.OnElementChanged(e);

            for (int i = 0; i < Control.Count; i++)
            {
                Object view = Control.GetItemAtPosition(i);
                TextCell cell = view.Cast<TextCell>(); //TableSection is just a TextCell

                if (cell != null)
                {
                    cell.TextColor = Color.Green;  unfortunately, there is to effect
                }
            }

        }
    }

    public static class ObjectTypeHelper
    {
        public static T Cast<T>(this Java.Lang.Object obj) where T : class
        {
            var propertyInfo = obj.GetType().GetProperty("Instance");
            return propertyInfo == null ? null : propertyInfo.GetValue(obj, null) as T;
        }
    }

Any suggestions?


Viewing all articles
Browse latest Browse all 58056

Trending Articles