locked
Image in button on navigation page disappears when button IsEnabled = False RRS feed

  • Question

  • Hi There,Anybody else come across this? Place a button on a navigation page and set its content to an image (a disc image to indicate a save button for instance). Set the button IsEnabled property to false. This is something you may want to do if for instance there are no changes to save. Navigate to the page inside a frame and at least on my machine, the image disappears. The image reappears when the button is enabled. Outside of a frame everything works as expected. It seems being inside a frame affects the rendering of the button content when the button is not enabled. I would be interested to know if this is expected behaviour or if I've missed something subtle.ThanksDelordson

    Sunday, June 13, 2010 3:44 AM

Answers

  • Hi,

    Update.

    It turns out it the real problem was with the BureauBlue theme that I was using. The designer of the theme had chosen to collapse the ContentPresenter of buttons whenever a button is in a disabled visual state.

     <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Visibility)">

        <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>

    </ObjectAnimationUsingKeyFrames>

     

    This is strange but I guess it is the designers’ prerogative. In any case the themes can be used as is but it is expected that you can tweak them to meet your particular needs. In my case, I have changed it so that Opacity of the ContentPresenter is reduced when the button is in a disabled state.


     <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">

        <SplineDoubleKeyFrame KeyTime="0" Value="0.35" />

    </DoubleAnimationUsingKeyFrames>

     

    Thanks

    Delordson

    Thursday, July 15, 2010 1:48 PM

All replies

  • Hi,

       Which Silverlight version you are using? Cause I just tested in Silverlight 4.

       The behavior is correct, I mean the Button renders correctly when disabled.(grayed out image showed up)

    Best Regards

    Tuesday, June 15, 2010 9:22 PM
  • Hi,

    Thanks for checking. I'm on Silverlight 4, VS2010. You are correct, I've checked in a brand new project and it does work. The project it failed in is one started in Silverlight 3 and later ported to the 4.

    Thanks

    Delordson

    Wednesday, June 16, 2010 2:21 AM
  • Hi,

    Update.

    It turns out it the real problem was with the BureauBlue theme that I was using. The designer of the theme had chosen to collapse the ContentPresenter of buttons whenever a button is in a disabled visual state.

     <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Visibility)">

        <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>

    </ObjectAnimationUsingKeyFrames>

     

    This is strange but I guess it is the designers’ prerogative. In any case the themes can be used as is but it is expected that you can tweak them to meet your particular needs. In my case, I have changed it so that Opacity of the ContentPresenter is reduced when the button is in a disabled state.


     <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">

        <SplineDoubleKeyFrame KeyTime="0" Value="0.35" />

    </DoubleAnimationUsingKeyFrames>

     

    Thanks

    Delordson

    Thursday, July 15, 2010 1:48 PM
  • Thank you, so much. This post saved my lot of time.

     

    Wednesday, August 25, 2010 1:19 PM
  • I changed the System.Windows.Controls.Theming.BureauBlue.xaml file in the following location

    C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Toolkit\Apr10\Themes\Xaml 

    But it doesnt wotk, i also have same problem as it is mentioned in this thread.

    so i need to do some thing more. i am very new to sliverlight.

     

     

    Thursday, September 2, 2010 3:44 AM