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

Foreground color of an image is changing to white when I click/press the ImageButton

4 Answers 614 Views
ImageButton
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
rajeev
Top achievements
Rank 1
rajeev asked on 01 May 2014, 11:34 AM
Hi,

I am assigning an image to imagebutton as RestStateImageSoure and setting Foreground color to Black. When I launch the App, it showing image in back color correctly. But when I press/hold the button, Image color is changing to white. How to change this behavior.

Thanks in advance

4 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 06 May 2014, 10:12 AM
Hi,

In this case you can redefine the PressedStateWithOpacityMaskForegroundFillBrush named brush that controls this behavior.

Let me know if this helps.

Regards,
Ivaylo Gergov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
rajeev
Top achievements
Rank 1
answered on 12 May 2014, 04:09 PM
Hi Ivaylo Gergov,

Thanks for your reply.

Could you explain how to define this. I have tried but couldn't find anything like "PressedStateWithOpacityMaskForegroundFillBrush ".

My code in .xaml:

<tp:RadImageButton  Background="{StaticResource PhoneColor}" x:Name="imgMobile" ButtonShape="Ellipse" ButtonType="Custom" RestStateImageSource="/Assets/Icons/Mobile_D.png" Foreground="Black"   Width="150" Height="150" />

in MainPage.cs:

         if (DeviceNetworkInformation.IsCellularDataEnabled)
            {
                imgMobile.RestStateImageSource = new BitmapImage(new Uri("/Assets/Icons/Mobile_E.png", UriKind.Relative));
                imgMobile.Foreground = new SolidColorBrush(Colors.White);
            }
            else
            {
                imgMobile.RestStateImageSource = new BitmapImage(new Uri("/Assets/Icons/Mobile_D.png", UriKind.Relative));
                imgMobile.DisabledStateImageSource = new BitmapImage(new Uri("/Assets/Icons/Mobile_D.png", UriKind.Relative));
                imgMobile.Foreground = new SolidColorBrush(Colors.Black);
            }
Where I need to implement your changes?












0
Accepted
Todor
Telerik team
answered on 13 May 2014, 11:16 AM
Hi,

You need to extract the template of the control by right-clicking it in Visual Studio's designer and choosing Edit Template -> Edit a Copy. This will extract the default style and you will be able to locate the PressedStateWithOpacityMaskForegroundFillBrush and change its value.

I hope this information helps.

Regards,
Todor
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
rajeev
Top achievements
Rank 1
answered on 14 May 2014, 05:56 AM
Thanks  Todor & Ivaylo Gergov

It solved my issue.
Tags
ImageButton
Asked by
rajeev
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
rajeev
Top achievements
Rank 1
Todor
Telerik team
Share this question
or