In your GetGlowingImage() method, you need to generate a new ImageSource
This link may help: Configure WPF image source in code
Edit:
See the difference in the fact that in WindowsForms code you have Properties.Resources._64px_Andromedahero ___ copia - this is the name of the Image variable that contains the image data. In your WPF code, the string "filename ...." is not the source of the image or image, but just a string representing the path to the file. You need to upload the image file using this path.
I know this does not make sense, because during development you can specify the file name, and it creates an ImageSource for you. In the code, you need to create an ImageSource (or a derived object, that is: BitmapSource) and load the corresponding image into it.
Edit: Try this, unverified (and check my link above):
public ImageSource GetGlowingImage(string name) { string fileName = string.Empty; switch (name) { case "Andromeda": { fileName = "HeroGlowIcons/64px-Andromeda.gif"; break; } } BitmapImage glowIcon = new BitmapImage(); glowIcon.BeginInit(); glowIcon.UriSource = new Uri("pack://application:,,,/ApplicationName;component/" + fileName); glowIcon.EndInit(); return glowIcon; }
Cory charlton
source share