Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
How to set a disabled image in a Toolbar?
posted

Hi,

The requirement I have is to set a disabled image to the toolbar and do not let the toolbar to "generate" the disabled image. How could I do this?

Thank you,

Ioan

 P.S. A quick and short answer would be appreciated.

Parents
No Data
Reply
  • 185
    posted

    I was just looking for the same thing today and found the following workaround: you can use the ImageBackground and ImageBackgroundDisabled to achieve the same effect. You need a transparent image of the same size as the ones for your button and set this transparent image as the button Image property. Then set ImageBackground to the enabled image you want and the ImageBackgroundDisabled to the image with the disabled state. Also set ImageBackgroundStyle to Centered if the image is smaller then the button (the default for the background is to strech and it looks bad).

    I had some trouble with the hot-tracked appeareance because it didn't seem to act as expected even if I manually override the Image* settings to the same settings as the normal appearance. It just shows a grey square when the mouse is over it. So I just set the hottracked Image property to the enabled image instead of the transparent image and left all other fields default. This is ok as the hottracking only takes place when the button is enabled anyway. I also set the pressed Image the same way just to be safe.

    Sample code from what the designer generated:

     

     

    appearance21.Image = global::BeGaze2.Properties.Resources.transparentImg; 

    appearance21.ImageBackground = global::BeGaze2.Properties.Resources.enabledImg;

    appearance21.ImageBackgroundDisabled = global::BeGaze2.Properties.Resources.disabledImg;

    appearance21.ImageBackgroundStyle = Infragistics.Win.ImageBackgroundStyle.Centered;

    buttonTool34.SharedProps.AppearancesLarge.Appearance = appearance21;

    appearance38.Image = global::BeGaze2.Properties.Resources.enabledImg;

    buttonTool34.SharedProps.AppearancesLarge.HotTrackAppearance = appearance38;

    appearance39.Image = global::BeGaze2.Properties.Resources.enabledImg;

    buttonTool34.SharedProps.AppearancesLarge.PressedAppearance = appearance39;

     

Children
No Data