This is a migrated thread and some comments may be shown as answers.

How can I changed the RadButton pressed highlight color?

3 Answers 420 Views
Button
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 20 Jun 2019, 05:16 PM

I need to change the color of a RadButton highlight when it's pressed.  It's currently a Grey and I need it to be white.  I understand theming, but can't find any documentation on what Color x:key values can be set for the RadButton.

 

Any help will be greatly appreciated.

3 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 21 Jun 2019, 05:34 PM
Hi John,

You can use the Pressed and Released event handlers to accomplish that. Here's an example:

<telerikInput:RadButton Text="Press Me"
                        BackgroundColor="White"
                        TextColor="DarkRed"
                        BorderColor="DarkRed"
                        BorderThickness="2"
                        WidthRequest="100"
                        HeightRequest="45"
                        VerticalOptions="Center"
                        HorizontalOptions="Center"
                        Pressed="Button_OnPressed"
                        Released="Button_OnReleased"/>

private void Button_OnPressed(object sender, EventArgs e)
{
    if (sender is RadButton btn)
    {
        btn.BackgroundColor = Color.DarkRed;
        btn.TextColor = Color.White;
    }
}
 
private void Button_OnReleased(object sender, EventArgs e)
{
    if (sender is RadButton btn)
    {
        btn.BackgroundColor = Color.White;
        btn.TextColor = Color.DarkRed;
    }
}


Native Approach

If this is not sufficient or you need to change other styles that are not available in the Xamarin.Forms API layer (i.e. hover), you will will to write a custom Renderer to override the native styling.  In case you want/need to do this, the renderer class to override is Telerik.XamarinForms.InputRenderer.[platform].ButtonRenderer.

Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
John
Top achievements
Rank 1
answered on 22 Jun 2019, 12:18 PM

Hi Lance, thank you for your reply. I thought of the above Button_OnPressed approach first, and it would be perfect, but it didn't work for me.  I tried again after your response, and I found that it will work for any color except for White(which is the background color assigned to this button in xaml)  If I set the background to Color.White, or Color.FromHex("#FFFFFF") the highlight is still Gray.  Any other color appears to work as you explain above.  This seems like a bug to me.  I'm using version 2019.2.513.1

It would be nice if this were a parameter "PressedHighlightColor" or styleable. 

 

0
Lance | Manager Technical Support
Telerik team
answered on 24 Jun 2019, 02:55 PM
Hi John,

This could be due to the native platform setting the styling that Xamarin.Forms doesn't override. In order for me to assist further, I'll need to know more about the application. 

- What version of Xamarin.Forms are you using? (if it's XF 4.x, please update to the latest UI for Xamarin release 2019.2.619)
- What are the target platform specifics? (the platform this is happening on and details like SDK and package dependencies).


Note: At your request, I can convert this to a Support Ticket because you have a Support License with your trial. You can attach a project to a ticket as well as fill in the platform details in a support Ticket. 

Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Button
Asked by
John
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
John
Top achievements
Rank 1
Share this question
or