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

Background for ImageButton

5 Answers 79 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.
Missing User
Missing User asked on 06 Feb 2013, 09:06 PM
Hello,

When i set my ImageButton shape to ImageButtonShape.Image the button background is not visible, what should i do?
also how can i set the background for different states like pressed, disable etc?

Thanks,
Shai

5 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 07 Feb 2013, 09:04 AM
Hello Shai,

Thank you for writing.

You can have a look at the examples we have here in our online documentation. In short, you have two options for providing images for RadImageButton.

First, you can provide an image with transparency as RestStateImageSource. This way the shape that this image contains (that is everything which is not transparent) will be colored with the value of the Foreground property of RadImageButton and the rest (the transparent part of the image) will be colored with the value of the Background property. The colors used for pressed and disabled states are hardcoded to be with the values that are default for the native Windows Phone buttons. If for some reason you need a different appearance you will have to edit the control template of RadImageButton and change the hardcoded values.

The second option you have, is to provide different images for the different states. In this case you don't need to take advantage of transparency, so the images that you provide will be used as they are including all transparency, white, black and other colors used in the image. Just when the button is pressed, the image provided as RestStateImageSource will be replaced with the one provided as PressedStateImageSource.

If you want to use the first option, the ImageButtonShape should be Rectangle or Ellipse depending what you want to be the shape of the button. If you prefer to provide the images by yourself (with all the necessary colors and disregarding the values of the Background and Foreground properties), you need to set the ImageButtonShape to Image.

I hope this clarifies the options you have when setting up RadImageButton.

Greetings,
Todor
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Missing User
answered on 07 Feb 2013, 10:48 AM
This seems very limited component, how can i have a situation to have a button with an image (normal image not stancile) with background color of my choice for each of the different states (to be changed in code not blend) ?
0
Todor
Telerik team
answered on 07 Feb 2013, 11:39 AM
Hello Shai,

If read thoroughly my previous post, you will notice that I have explained all possible scenarios and the way to achieve them with RadImageButton. Naturally, the control is created in a way such that the most common scenarios are easiest to accomplish and the not-so-popular scenarios (like having a button which has a background for the pressed state different than the one the users would expect) are harder to achieve. You can try to set the background for the pressed state of the native windows phone button and you will see that this is not an easy task as well.

Your scenario seems like the first one I've described. You need to remove the background from the image, since the only way for the control to know the difference between foreground and background is by transparency. Then, by using Blend or Visual Studio 2012, you can easily extract the default style of the control and change the values that concern you. If you don't want to use Blend and you don't have Visual Studio 2012, I can give you the default style of the control and show you where to add the colors that you want for the pressed state of the button.

Greetings,
Todor
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Missing User
answered on 07 Feb 2013, 11:55 AM
Yes, please give me the xaml default state/template for RadImageButton.
0
Todor
Telerik team
answered on 07 Feb 2013, 12:57 PM
Hello Shai,

I have attached a sample application with the style of RadImageButton. In the resources of the MainPage you will find six resources: foreground and background fill and stroke for both pressed and disabled state. Actually you just need to change the values for these brushes and you can leave the style of the control itself as it is.

Let me know if you need additional assistance.

Greetings,
Todor
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
ImageButton
Asked by
Missing User
Answers by
Todor
Telerik team
Missing User
Share this question
or