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

Change Toolbaritem color through pagerenderer for Android

$
0
0

Hi,

Can someone guide me how to change the toolbaritem text color through using custom pagerenderer please?

Here is what I have

        public class ExtendedContentPage : ContentPage
        {
            public static readonly BindableProperty ItemColorProperty =
                BindableProperty.Create<ExtendedContentPage, Color>(p => p.ItemColor, Color.Gray);

            public Color ItemColor
            {
                get { return (Color)GetValue(ItemColorProperty); }
                set { SetValue(ItemColorProperty, value); }
            }
        }

    [assembly: ExportRendererAttribute(typeof(ExtendedContentPage), typeof(ExtendedContentPageRenderer))]
        public class ExtendedContentPageRenderer : PageRenderer
        {
            View view;

            protected override void OnElementChanged (ElementChangedEventArgs<Page> e)
            {
                base.OnElementChanged (e);

                //how to I reference the toolbaritem and the itemColor property that I created to change the toolbaritem text color?
            }
        }

        public partial class Load : ExtendedContentPage
        {   
            public Load ()
            {
                InitializeComponent ();

                ItemColor = Color.Red;

                ToolbarItems.Add(new ToolbarItem("Cancel",string.Empty, async () => await Navigation.PopModalAsync()));
            }
        }

Many thanks!


Viewing all articles
Browse latest Browse all 58056

Trending Articles