WPF图像在运行时不呈现

时间:2014-11-14 21:24:24

标签: c# wpf

我有一组从我的解决方案资源文件加载的图像,现在它们在设计模式和Blend中显示正常,但是当我实际运行程序时它们根本不会显示。

以下是控件的标记

<WrapPanel x:Name="heartsWrapPanel" Height="25.97" Canvas.Left="437.94" Canvas.Top="594.83" Width="75.26">
    <Image x:Name="heart1" Height="22.388" Width="24.777" HorizontalAlignment="Left" VerticalAlignment="Bottom" Source="pack://siteoforigin:,,,/Resources/heart.png"/>
    <Image x:Name="heart2" Height="22.388" Width="24.777" HorizontalAlignment="Left" VerticalAlignment="Bottom" Source="pack://siteoforigin:,,,/Resources/heart.png"/>
    <Image x:Name="heart3" Height="22.388" Width="24.777" HorizontalAlignment="Left" VerticalAlignment="Bottom" Source="pack://siteoforigin:,,,/Resources/heart.png"/>
</WrapPanel>

现在我无法弄清楚什么是错的,包装面板没有任何问题,因为我试图将其他元素放入其中并且它们显示得很好,就像我说的那样,图像显示在设计模式中在Blend中但它不会在运行时显示。

1 个答案:

答案 0 :(得分:1)

您必须将&#34;构建操作&#34; 设置为图像的&#34;资源&#34; 并且可能更改为 Source = Resources / XXX.png&#34;

相关问题