How can I show a button is clicked(pressed) in WPF?

I'm not sure what you want visually, but if you want the border to change color when the button is pressed down, you would modify your template like this:

<Style TargetType="Button" x:Key="TransparentButton">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Border Name="border" Background="Transparent" BorderThickness="1" BorderBrush="Black">
                    <ContentPresenter/>
                </Border>

                <ControlTemplate.Triggers>
                    <Trigger Property="Button.IsPressed" Value="True">
                        <Setter TargetName="border" Property="BorderBrush" Value="Transparent" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

When you recreate the ControlTemplate of the button you lose all the default features of the windows button feel. You would need to recreate them with triggers, or not use your own control template.

<ControlTemplate.Triggers>
   <Trigger Property="IsPressed" Value="True">
       <Setter ....behavior you want
   </Trigger>
</ControlTemplate.Triggers>

Here's a link to MSDN default control template a button has, you can use it as a reference to recreate some of the behavior you have lost by defining your own.

http://msdn.microsoft.com/en-us/library/ms753328%28v=vs.85%29.aspx

Tags:

C#

Wpf