Background for ImageButton

6 posts, 0 answers
  1. Missing user
    Missing user avatar

    Posted 06 Feb 2013 Link to this post

    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
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 07 Feb 2013 Link to this post

    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.
  3. DevCraft banner
  4. Missing user
    Missing user avatar

    Posted 07 Feb 2013 Link to this post

    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) ?
  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 07 Feb 2013 Link to this post

    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.
  6. Missing user
    Missing user avatar

    Posted 07 Feb 2013 Link to this post

    Yes, please give me the xaml default state/template for RadImageButton.
  7. Todor
    Admin
    Todor avatar
    778 posts

    Posted 07 Feb 2013 Link to this post

    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.
Back to Top
DevCraft banner