开发者

How can I set an image to the Image control in WPF?

开发者 https://www.devze.com 2022-12-13 20:58 出处:网络
I\'m doing this: <Image Grid.Column=\"0\" Grid.Row=\"0\" x:Name=\"Andromeda\" Source=\"/Resource开发者_如何学运维s/64px-Andromedahero.gif\" />

I'm doing this:

<Image Grid.Column="0" Grid.Row="0" x:Name="Andromeda" Source="/Resource开发者_如何学运维s/64px-Andromedahero.gif" />

But it's just not working. :S

Here's a screenshot of the file/folder hierarchy. Any help?

How can I set an image to the Image control in WPF?


A couple of potential options:

  1. Make sure that your resources are set to be compiled as embedded resources.
  2. If this is a control library, and you're using this from a separate application, you may need to use a Pack URI.

Edit:

If it's a control library, you'll want to use:

Source="pack://application:,,,/MyControlLibraryAssembly;component/Resources/64px-Andromedahero.gif"
0

精彩评论

暂无评论...
验证码 换一张
取 消