Поделиться через


How to: Assign an Image to an Image Control

You can display an image in your Windows Presentation Foundation (WPF) application by using the Image control. This topic shows how to add an image resource to your project and display it by using the WPF Designer for Visual Studio.

To assign an image by using the Properties window

  1. In Solution Explorer, right-click your WPF project, point to Add, and then select Existing Item….

    The Add Existing Item dialog box opens.

  2. In the Add Existing Item dialog box, set the type drop-down list to display images files and navigate to the image that you want to display.

  3. Select the image and click Add.

    The image is added to the project.

  4. In Solution Explorer, select the image file.

  5. In the Properties window, make sure that the Build Action property is set to Resource.

  6. Add an Image control to the design surface.

  7. In the Properties window, click the Source property for the Image control.

  8. Select the image that you added from the drop-down list.

    Your image is displayed in the Image control.

To assign an image by using pack URI syntax

See Also

Reference

Image

Concepts

Pack URIs in WPF

Other Resources

Using Resources

Working with Controls in the WPF Designer