Images in a WPF Custom Control Library

不羁岁月 提交于 2019-12-06 15:27:40
Sergey Aldoukhov

That's probably because you specified the image path as a relative path. You should use the Pack URI Scheme to specify that the resource is in the current assembly. For instance :

<Image Source="pack://application:,,,/Images/MyImage.png"/>

I have an open-source library that allows you to include country flags in your WPF application via a value converter. The flags images are stored as resources within the assembly.

It's available on NuGet:

Install-Package FamFamFam.Flags.Wpf

The source is up on GitHub:

https://github.com/drewnoakes/famfamfam-flags-wpf

You can take a look to see how the images are embedded and the Pack URI scheme is used.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!