❔ Embed images within .exe [WPF App .Net 6.0]
Hey, I have some Images that I would like to use within my app, how do I have them embedded within the .exe, I tried to do
But, then it tries to get the images from the build output/images/theimage.png
How do I have them within the .exe, I was able to do this in older version of WPF
Thanks
45 Replies
you want to include them as resources
that should work in wpf
How do I do that?
exchange Content with Resource
Okay, I'll give it a go, thanks
or do it in the designer of course
or not designer, the file properties window
Like this?
i would think so?
No, doesn't work still...
how are you trying to access this?
Like this, from xaml
oh, actually content was correct lol
articles online say you need to
CopyIfNewer
So not resource?
but this makes me wonder whether it will work without having to ship the images along the binaries
<Resource Include="..">
should workWith Content instead of Resource, it still doesn't work
If I do the content one, it tries to find it from the build output folder
.
Where do I use that?
You don't need CopyIfNewer with Resource
But it doesn't work with Resource Include
I get this
Hmmm, that's odd I have a wpf project open and it works
How do you point to it
From XAML
where is your images folder?
relative to the csproj file?
The same
what?
In csproj
<Resource Include="Resources\doc.png">
In XAML
It also shows them in the XAML editor, its only when I run it
well they're not using an
Image
might be thatIn csjproj:
`<Resource Include="Images/Background.png" />``
XAML
Grid.Background can only accept ImageBrush
why would you do it like that then lmao
why not add an image over the full row and columnspan
How would you do it then?
I cannot leave them empty
so add the numbers you need...
Idk which numbers I need
I just want the background of the whole page to be the image
however many rows and columns the grid has
None
so the image spans over the entire grid
so put 0 or remove them
and come on
❯ AttachedProperty: System.Windows.Controls.Grid.RowSpan
Gets or sets a value that indicates the total number of rows that child content spans within a Grid.
❯ Field: System.Windows.Controls.Grid.RowSpanProperty
Identifies the RowSpan attached property.
React with ❌ to remove this embed.
I haven't used grids with that before lol, I also tagged it as beginner
If you still want to use ImageBrush
Should work
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.