✅ Font Awesome in WPF
Hi I added Fontawesome Nugget Package to my WPF project (FontAwesome.Sharp)
and when I try to add an Icon like
Any Fixes?
<fa:IconImage Icon="AngleLeft"/>
it gives me the following
Severity Code Description Project File Line Suppression State
Error XDG0003 Could not load file or assembly 'FontAwesome.Sharp, Version=6.3.0.0, Culture=neutral, PublicKeyToken=d16d1e4e568ec10f'. The system cannot find the file specified.Any Fixes?
10 Replies
Never fully trust any XDG* errors as those are related to the designer. Build the app, try to run it, see what happens. Check the Build Output in the build fails.
Ohh it fixed icic
tysm
I can't really tell you why this particular error happens. Sometimes you just need to rebuild, but sometimes the designer is just misleading.
When I was using WPF, I preferred disabling the designer altogether because of these issues (and others) and instead use XAML Hot Reload for layout/styling.
that makes sense. btw since we on topic of WPF another quick question. I have the following
<Image x:Name="ImageLogout" HorizontalAlignment="Left" Height="40" Margin="20,120,0,0" VerticalAlignment="Top" Width="40" Source="/Assets/Images/ImageLogout.png" Grid.Row="1"/>
but hte image doesn't load even tho the source is correct (no error is given it just doesn't load)1. Did you make sure the element is being laid out correctly and is indeed visible?
2. Did you make sure the source is correct? (by loading an image in code-behind and breaking with the debugger to see it succeed)
Also, you need to set the Build Action of the image to Resource.
Yes I have put the image as Resource
So if it loads in one spot and not another, then the problem isn't image loading. Your problem is layout.
This is another classic pitfall of the WPF designer: using
Margin
for positioning instead of proper use of layout containers.
Margin
is best used when you're pushing a control a few (maybe 20) pixels for minor spacing adjustments.
Once you start pushing controls over each other and using Margin
for absolute placement, your layouts will resize with very buggy behavior.
I don't know if the XAML has been trimmed from the original to show us, but stuff like this doesn't make sense either:
The first row is 317 parts of proportional representation and the second row is 205 pixels...which doesn't make sense. Just do * and 205 if that's the case.Ye I don't have much experiene in WPF and have been self learning so this type of issues is still new things to me.
and the image fixed once I removed the 'Stretch'
Ty for all help
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.