2017-07-11 42 views
0

我想在WPF应用程序中添加图像。我希望嵌入图像,以便应用程序可以从任何系统加载该图像,而不仅仅是我的图像。我搜索并找到了一些解决方案。将我的构建操作更改为资源。但是将鼠标悬停在源上,它显示出与我的工作区不同的路径。问题是什么? (安装在图像不正确的路径)C#中WPF应用程序中的图像源不正确

<DockPanel HorizontalAlignment="Left" Height="144" Margin="0,1,0,0" Grid.Row="0" VerticalAlignment="Top" Width="519" Background="#FFA02C2C" > 
     <Image x:Name="image" Grid.Row="0" Source="FriendsRandomEpisode;component/Images/Friends.jpg"/> 
</DockPanel> 

This image shows the incorrect path

+0

尝试设置路径:'Source =“Images/Friends.jpg”' – Fruchtzwerg

+0

@Fruchtzwerg好吧。有效。非常感谢。提交答案,以便我可以接受。 –

回答

1

不需要设置任何部件在源如果图像是在相同的组件。只需设置来源如

Source="Images/Friends.jpg" 
相关问题