Click here to Skip to main content
15,920,801 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hello,
i hope there is anybody who can help me. I am using a standard wpf Button. But i dont want the hover effekt to be displayed when the mouse enters the control. Is there any other option, to get rid of this effekt, except using a Control Template?
Maybe there is the possibility of changing the System Brush to transparent or somthing?

thanks for help
greets moti
Posted

See the second answer here for a way to make a WPF button without the built-in mouse over animation effect, that still has the simple mouse over effect of showing the button border in black. The key section there is the section
C#
<trigger property="IsMouseOver" value="True">
.
.
.
</trigger>


You can put any kind of action you want for MouseOver in there or get rid of the effect altogether.
 
Share this answer
 
Comments
Motil88 4-May-12 2:36am    
THX this helped a lot, was exactly what i wanted ;)
BillW33 4-May-12 8:42am    
You are very welcome. Remember you can also vote for good answers as well as marking the best one as "the solution". :)
VJ Reddy 15-May-12 10:50am    
Good answer. 5!
BillW33 15-May-12 20:16pm    
Thanks, VJ
You have to make your own button. (As far as I know) Mark H. made a tutorial on this. (see link)

Creating Custom WPF-Buttons [^]
 
Share this answer
 
Comments
Motil88 3-May-12 8:14am    
Thanks for quick answer, i was afraid that i would have to do this ;)
greets moti
(__Aaron__) 3-May-12 10:33am    
Good.
XML
If someone doesn't want to override default Control Template then here is the solution.

You can create DataTemplate for button which can have TextBlock and then you can write Property trigger on IsMouseOver property to disable mouse over effect. Height of TextBlock and Button should be same.

        <Button Background="Black" Margin="0" Padding="0" BorderThickness="0" Cursor="Hand" Height="20">
                        <Button.ContentTemplate>
                            <DataTemplate>
                                <TextBlock Text="GO" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" TextDecorations="Underline" Margin="0" Padding="0" Height="20">
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock">
                                            <Style.Triggers>
                                                <Trigger Property ="IsMouseOver" Value="True">
                                                    <Setter Property= "Background" Value="Black"/>
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>
                            </DataTemplate>
                        </Button.ContentTemplate>
                    </Button>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900