Silverlight:为什么png图像不显示?

发布于 2024-09-13 16:37:54 字数 534 浏览 3 评论 0原文

在Silverlight 4应用程序中,图像很少,两者都在设计模式下正确显示,一个在运行时也正确显示:

<Image Height="180" Width="149" Source="../Picts/Field.png" />

另一张在运行时不显示:

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5" Visibility="{Binding SquadSavedVisibility, Mode=OneWay}">
    <Image Source="..\Picts\ok.png" Width="16" Height="16" />
    <TextBlock Text=" It is saved" Foreground="Green"/>
</StackPanel>

为什么?以及如何让它显示出来呢?

欢迎任何想法。谢谢。

In Silverlight 4 application there are few images, both are displayed correctly in design mode, one is displayed correctly in run-time also:

<Image Height="180" Width="149" Source="../Picts/Field.png" />

Another one is not displayed in run-time:

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5" Visibility="{Binding SquadSavedVisibility, Mode=OneWay}">
    <Image Source="..\Picts\ok.png" Width="16" Height="16" />
    <TextBlock Text=" It is saved" Foreground="Green"/>
</StackPanel>

Why? And how to get it displayed?

Any thoughts are welcome. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

坠似风落 2024-09-20 16:37:54

一切都在你的斜杠中,VS设计时不介意你使用“..\Picts\ok.png”,但Silverlight运行时希望看到“../Picts/ok.png”。换句话说,你的斜杠很重要。

It's all in your slashes, VS Design time doesn't mind you using "..\Picts\ok.png", but Silverlight runtime wants to see "../Picts/ok.png". In other words, your slashes matter.

深海里的那抹蓝 2024-09-20 16:37:54

我在设计时显示图像时遇到了类似的问题,但在运行时却没有。我的使用的是包 URI,所以我也想发布该修复:

在运行时不起作用,在设计时起作用:

;

在设计和运行时均有效:

请注意 Pack URI 开头之前的额外“/” 。

I had a similar problem with images showing in design-time, but not at runtime. Mine was using a pack URI so I wanted to post that fix as well:

Does not work at runtime, does work at design-time:

<Image Source="mydllname;component/Images/logo.png" />

Works at both design and runtime:

<Image Source="/mydllName;component/Images/logo.png" />

Note the extra '/' before the Pack URI starts.

柠檬 2024-09-20 16:37:54

您可以尝试挂钩 Image.ImageFailed 事件。有关示例和更多说明,请查看此页面:
http: //msdn.microsoft.com/en-us/library/system.windows.controls.image.imagefailed%28v=VS.95%29.aspx

You can try to hook into the Image.ImageFailed Event. For examples and more explanation you look into this page:
http://msdn.microsoft.com/en-us/library/system.windows.controls.image.imagefailed%28v=VS.95%29.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文