Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-create-a-button-that-has-an-image.md
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

1.4 KiB
Raw Permalink Blame History

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Create a Button That Has an Image 03/30/2017
csharp
vb
Button controls [WPF], creating
607a193c-4098-4dd8-8dc0-51256cec2020

How to: Create a Button That Has an Image

This example shows how to include an image on a xref:System.Windows.Controls.Button.

Example

The following example creates two xref:System.Windows.Controls.Button controls. One xref:System.Windows.Controls.Button contains text and the other contains an image. The image is in a folder called data, which is a subfolder of the examples project folder. When a user clicks the xref:System.Windows.Controls.Button that has the image, the background and the text of the other xref:System.Windows.Controls.Button change.

This example creates xref:System.Windows.Controls.Button controls by using markup but uses code to write the xref:System.Windows.Controls.Primitives.ButtonBase.Click event handlers.

[!code-xamlBtnColor#4]

[!code-csharpBtnColor#6] [!code-vbBtnColor#6]

See also