Note that there are some explanatory texts on larger screens.

plurals
  1. POChange Button Image On Hover or Click
    primarykey
    data
    text
    <p>How do I change the background image of a Button on Hover and on Click? The Visual Studio's UI does not seem to provide any easy way of doing it. Currently the default behavior seems to replace my image with a solid color, which looks aweful.</p> <p>All I have so far is the Button base:</p> <pre><code> &lt;Button Content="" Height="75" VerticalAlignment="Center" Width="75" HorizontalAlignment="Center" ClickMode="Press"&gt; &lt;Button.Background&gt; &lt;ImageBrush ImageSource="../data/images/icons/skill_icon_0.png"/&gt; &lt;/Button.Background&gt; &lt;/Button&gt; </code></pre> <p>I tried to handle events and manually set it, but it doesn't work for Pressed/Released:</p> <pre><code> Button skillButton = new Button(); skillButton.Width = 75; skillButton.Height = 75; skillButton.ClickMode = ClickMode.Press; skillButton.Background = GetIconImage(iconIndex, 0); skillButton.PointerEntered += (object sender, Windows.UI.Xaml.Input.PointerEventArgs e) =&gt; { skillButton.Background = GetIconImage(iconIndex, 1); }; skillButton.PointerExited += (object sender, Windows.UI.Xaml.Input.PointerEventArgs e) =&gt; { skillButton.Background = GetIconImage(iconIndex, 0); }; skillButton.PointerPressed += (object sender, Windows.UI.Xaml.Input.PointerEventArgs e) =&gt; { skillButton.Background = GetIconImage(iconIndex, 2); }; skillButton.PointerReleased += (object sender, Windows.UI.Xaml.Input.PointerEventArgs e) =&gt; { if (skillButton.FocusState == FocusState.Pointer) skillButton.Background = GetIconImage(iconIndex, 1); else skillButton.Background = GetIconImage(iconIndex, 0); }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload