0
Good morning, you guys.
I’m making a weather app for the course I’m doing and the weather icons we pull direct from links on the internet.
How I would do it locally?
The Icon is specified by an int Weathericon variable.
I downloaded the images, and put them in the project Resource with the name referring to her number in veritable to facilitate, as it is on the site. Both over the internet and through the full path of the image I just put the variable in the path and ready:
@"~\..\..\WIcon\" + Condition.WeatherIcon.ToString() + ".png"
How I could place this image that is in the project’s Source, being specified by this variable, inside a picturebox?
EDIT:
Weathervm.Cs
public Bitmap Icon
{
get
{
ResourceManager rm = Resources.ResourceManager;
Bitmap icone = (Bitmap)rm.GetObject(Condition.WeatherIcon.ToString() + ".png");
return icone;
}
}
XAML
<Image DataContext="{StaticResource vm}"
Source="{Binding Icon}"/>
I did this but it doesn’t appear in the designer. I edited the question by putting part of the code. What I’m doing wrong?
– Raphael Aracelli
From the research I’ve done you need a
BitmapImage
instead ofBitmap
. If you put a name in this pictureBox, you can change by code even usingBitmap
?– Natan Fernandes