图像不会在WPF中显示

时间:2014-04-05 21:52:13

标签: c# wpf image xaml

我是C#和WPF的新手,并试图创建一个显示图片的非常基本的程序。所以在XAML文件中我输入了这段代码:

<Image HorizontalAlignment="Left" Height="100" Margin="184,143,0,0" 
       VerticalAlignment="Top" Width="100" Source="image.jpg"/>

它出现在编辑器(Visual Studio)中但是当我运行程序时似乎已经消失了!这是整个代码:

<Window x:Class="Follow.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Image HorizontalAlignment="Left" Height="100" Margin="184,143,0,0" 
               VerticalAlignment="Top" Width="100" Source="bp.jpg"/>
    </Grid>
</Window>

感谢您的帮助,我一直在寻找,但似乎无法找到答案!

1 个答案:

答案 0 :(得分:0)

在Visual Studio中,在存储映像的资源下,确保将构建操作设置为resource。 Here是一个类似的问题,答案更详细。

相关问题