Resource

WPF Button with Image

Soft Dev Resources May 14, 2009
This resource shows how to create a button with image in it in WPF.
  • 0
  • 0
  • 165350
The following example creates two Button controls. One Button contains text and the other contains an image. When a user clicks the Button that has the image, the background and the text of the other Button change.

This example creates Button controls by using markup but uses code to write the click event handlers.

XAML code:
<Button Name="AButton" Width="50" Height="30" Click="OnImageButtonClick">
<Image Source="data\YourImageName.jpg"></Image></Button>
<Button Name="Button2" BorderBrush="Black">Click the picture.</Button>
Here is the button click event handler.

void OnImageButtonClick(object sender, RoutedEventArgs e)
{
Button2.FontSize = 16;
Button2.Content = "This is an image";
Button2.Background = Brushes.Red;
}
COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

TOP RESOURCES

MOST LIKED RESOURCES