locked
Button loses its background after moving to Silverlight 4 RRS feed

  • Question

  • I have some buttons like 

                        <Button x:Name="LoginButton" Grid.Row="2" Grid.Column="1" Margin="0, 5" Width="80" HorizontalAlignment="Left" Content="OK" Click="LoginButton_Click" />

    In SL4 button background appears only if mouse is in button. In this case button background appers as yellow. If mouse is moved out of button, button background is not shown, only lettes OK appear.

    How to fix this so that button background is shown always ?

    Andrus.

     

    Thursday, May 27, 2010 1:26 PM

Answers

  • Does the issue occur on a particular Page or UserControl?  For testing purposes, you can create a new usercontrol, throw in a button, and see if that button is getting the same effect.

    The issue sounds like there could be a global or implicit style that is attached to the button. Look in Generic.xaml and App.xaml to see if there are any implicit button styles.

     

    <Style TargetType="Button">
    </Style>
    
    <ControlTemplate TargetType="Button">
    </ControlTemplate>
     
    Thursday, May 27, 2010 2:13 PM

All replies

  • If you background is yellow this is obviously a custom button that may be utilizing some kind of style. Take a look at the visual states or storyboard connected to the button and compare the base/normal to mouseover states (or various storyboards/events) to see what properties are being changed.

    Thursday, May 27, 2010 1:30 PM
  • I do'nt have any custom styles: 

    <Button x:Name="LoginButton" Grid.Row="2" Grid.Column="1" Margin="0, 5" Width="80" HorizontalAlignment="Left" Content="OK" Click="LoginButton_Click" />

    this is only simple Button tag which should draw standard button with gray background.

    Andrus.

    Thursday, May 27, 2010 1:34 PM
  • This is very strange then. Where is the yellow coming from? The above code produces a normal button for me. There is no default style or defined template in some reference, theme, namespace, generic.xaml, app.xaml, or some resource dictionary or anything thats being used? If not I am not sure what your options are here. Does this happen in the designer or blend, runtime, or all the above? What OS? All browsers?

    Thursday, May 27, 2010 1:43 PM
  • Where is the yellow coming from?

    No idea. Color is really orangeyellow , not pure yellow. This is big application but I don't rememnber that such color is used in applicaton.

    application conains Tim Heuer's AutocompleteCombo dropdown buttons. Their background will also change to this color. For dropdown buttons, this color remains sometimes after mouse is moved out or button, sometimes background color is removed like in login form OK button. I can send you application link privately or create video if you need this.

    There is no default style or defined template in some reference, theme, namespace, generic.xaml, app.xaml, or some resource dictionary or anything thats being used?

    there is no generic.xaml file. app.xaml is full of styles but those are not applied to <Button> tag as far as I know. No idea how to search application code for global style appliance. Application code contains lot of files.

    Does this happen in the designer or blend, runtime, or all the above?

    It  happens in runtime. Designed does not show login form,( it complains that cannot open base class). form with dropdown buttons is generated dynamically so it is avaliable only at runtime. I do'nt have blend installed.

    What OS?

    Windows vista 

    All browsers?

    It happens in IE and in Firefox. Havent tried others.

    Andrus.

    Thursday, May 27, 2010 2:03 PM
  •  Hmm. You could try searching the code for:

    button.Style

    button.Style = (Style)(Application.Current.Resources

    .Style =

    Application.Current.Resources

    etc.. to see if there is a button style applied programmatically

    or you could search in xaml for:

    TargetType="

    TargetType="button"

    to see if there is some global resource defining a style

    also can search on resource dictionary to see if any theme or dictionary is getting applied on global level..

    Thursday, May 27, 2010 2:10 PM
  • Does the issue occur on a particular Page or UserControl?  For testing purposes, you can create a new usercontrol, throw in a button, and see if that button is getting the same effect.

    The issue sounds like there could be a global or implicit style that is attached to the button. Look in Generic.xaml and App.xaml to see if there are any implicit button styles.

     

    <Style TargetType="Button">
    </Style>
    
    <ControlTemplate TargetType="Button">
    </ControlTemplate>
     
    Thursday, May 27, 2010 2:13 PM