According to this documentation, it is possible to reference a local image with the same file name across different platforms in shared Xamarin Forms code.
There are instructions on where the image files should be located and what the build action should be set to for iOS, Android, Windows Phone and UWP projects.
Unfortunately, instructions are missing for the recently released WPF preview of Xamarin Forms.
Where should the local image files be placed, and what should the build action be set to in a WPF Xamarin Forms project?
Set a build action of Content
for your images, assumably in the Assets
folder
FYI: There are 3 registered WPF image sources in Forms
FileImageSourceHandler
StreamImageSourceHandler
UriImageSourceHandler
Forms WPF Image Source
Additional Info from @AndersGustafsson
Build Action Content is the same build action as for Windows Phone and UWP platforms.
It seems like you are required to copy the image file to the output directory for the image to be recognized by the WPF application. This is different from UWP, where copying is not required.
It is OK to add the image file as a link in the WPF project. If I am not mistaken, this is not allowed in UWP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With