2

I just created the wpf button and when I click on the button, it changed to white color like flashing and change back to original color when I release the button. What could be the problem? I didn't use any effect. Below is my button xaml. please advice.

<Button Content="ROM" Height="121" HorizontalAlignment="Left" Margin="91,269,0,0" Name="button1" VerticalAlignment="Top" Width="566" FontSize="48" BorderBrush="#FF3DFF00" BorderThickness="10" Foreground="White">
            <Button.BitmapEffect>
                <DropShadowBitmapEffect ShadowDepth="2" Color="Gray"></DropShadowBitmapEffect>
            </Button.BitmapEffect>
            <Button.Background>
                <RadialGradientBrush>
                    <GradientStop Color="#FF4094D8" Offset="0" />
                    <GradientStop Color="#FF2B476F" Offset="1" />
                </RadialGradientBrush>
            </Button.Background>
        </Button>
Felice Pollano
  • 32,832
  • 9
  • 75
  • 115
TNA
  • 616
  • 1
  • 9
  • 25

2 Answers2

2

One method is to place a transparent button on top of an image that looks like a button, then set the button's opacity value to zero.

<Image Name="buttonImage1" Source="../Images/infoButton.png" Grid.Row="1"/>
<Button Name="infoButton" Tap="infoButton_Tap" Opacity="0.0" BorderBrush="Transparent" Grid.Row="1"/>
YarsRevenge13
  • 151
  • 1
  • 8
1

This is becuase of the default ButtonChrome. if you extract the default details from Expression blend of the button

<Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Microsoft_Windows_Themes:ButtonChrome x:Name="Chrome" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" RenderDefaulted="{TemplateBinding IsDefaulted}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"/>
                    </Microsoft_Windows_Themes:ButtonChrome>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true">
                            <Setter Property="RenderDefaulted" TargetName="Chrome" Value="true"/>
                        </Trigger>
                        <Trigger Property="ToggleButton.IsChecked" Value="true">
                            <Setter Property="RenderPressed" TargetName="Chrome" Value="true"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="#ADADAD"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Microsoft_Windows_Themes:ButtonChrome is setting the effect. If you want to remove or modify the effects you have to create your own controltemplate or style

Kishore Kumar
  • 21,449
  • 13
  • 81
  • 113
  • I'm using the Visual Studio. I just don't want the button to change color when I press. I mean I want it like the window form button. Do i still need to come out my own control template? – TNA Feb 15 '11 at 08:57