Dotnet Dotnet - 9 months ago 93
C# Question

WPF issue with button background image

I have my wpf button as follows

<Button x:Name="helpButton" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="552,201,95,726" Width="32" Height="32" BorderThickness="0" Click="helpButton_Click">
<ImageBrush ImageSource="/Images/help-icon1.png"></ImageBrush>

On window load I am able to see the image perfectly but when I hover the mouse I am not able to see the image

enter image description here

So can some one help me

Jim Jim
Answer Source

A more sensible approach to start would be by using <Button.Template> instead of <Button.Background>

<Button x:Name="helpButton">
            <Border HorizontalAlignment="Center" VerticalAlignment="Center" >
                <Image Source="/Images/help-icon1.png" Width="32" Height="32"/>