Languages

Menu
Sites
Language
How to change the white color on a focused button (TV)

Hello,

How can i change the white background color that appears when the button gets focused? (xamarin forms)    

 

View Selected Answer

Responses

3 Replies
Tizen .NET

Hi,

You can change the background color of button when it's focused by changing "bg_focused" part color of native button of Tizen platform.

To do this, you need to customize Xamarin.Forms.Button.

 

namespace ColorTest

{
    class MyButton : Xamarin.Forms.Button
    {
    }
}

 

[assembly:ExportRenderer(typeof(MyButton), typeof(MyButtonRenderer))]
namespace ColorTest
{
    class MyButtonRenderer : ButtonRenderer
    {
        public MyButtonRenderer() : base()
        {
        }

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            if (e.PropertyName == Button.IsFocusedProperty.PropertyName)
            {
                Control.SetPartColor("bg_focused", ElmSharp.Color.Orange);
            }
        }

    }
}

Instead of Xamarin.Forms.Button, you can use MyButton to change the background color of focused button.

FYI, you can get more about "Custom Renderer" from  here

Thanks.

Mark as answer
Tizen .NET

MyButtonRenderer is updated.

[assembly:ExportRenderer(typeof(MyButton), typeof(MyButtonRenderer))]
namespace ColorTest
{
    class MyButtonRenderer : ButtonRenderer
    {
        public MyButtonRenderer() : base()
        {
        }

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

            Control.SetPartColor("bg_focused", ElmSharp.Color.Lime);

        }
    }
}

 

Moon Developer

Hey,

I did try the renderer, the key point that I did not know was the "bg_focused". Where can i find more about those "parts" of the controls?