Set Background Color of Tapped, or Clicked Button RRS feed

  • Question

  • I am writing to ask how best to set the background color of a Button - if tapped, or clicked;

    The button utilizes an image as the background;

    Thanks in advance for any insight;

    <Button x:Name="btnxxx" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="btnxxxx_Click" Width="300" Height="116">
                        <ImageBrush ImageSource="Images/xxxxSmall.jpg"/>


    robert hellestrae

    Saturday, October 27, 2012 8:58 PM


  • Hi Robert,
    You can look at how this works in the Button style defined in Program Files (x86)\Windows Kits\8.0\include\design\xaml\generic.xaml

    The pressed state changes the background to the ButtonPressedBackgroundThemeBrush.

    If you want to change this for individual buttons you'll can create a new template which handles the background as you'd like. The easiest way is to select your button in the designer and choose "Edit Template..." from the context menu.


    Saturday, October 27, 2012 10:51 PM