Сохраните эту картинку к себе на компьютер
Скачать ...
Файл MainWindow.xaml
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Canvas x:Name="MyCanvas1" Margin="74 80 0 0" Width="200" Height="140">
</Canvas>
</Grid>
</Window>
В файле MainWindow.xaml.cs напишем код:
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace WpfApp1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// create image
Image image = new Image();
// load image from resource
string pathImage = "pack://application:,,,/WpfApp1;component/tree.jpg";
image.Source = new BitmapImage(new Uri(pathImage, UriKind.Absolute));
// add image to canvas
MyCanvas1.Children.Add(image);
}
}
}