Setting an image.Source from a resource file
14,320
set source to new BitmapImage(new Uri("C:\Users\Sergio\Documents\Visual Studio 2008\Projects\emailwpf\emailwpf\ok.png"))
You can set in XAML to string value, because registered converter is used under the hood;
Author by
Sergio Tapia
I'm a 21 year old professional programmer that likes to read about a wide range of things related to programming. Currently, I'm pounding away at ASP.Net MVC2.
Updated on June 27, 2022Comments
-
Sergio Tapia almost 2 years
private void SetCredentials() { username = txtfromEmail.Text; password = txtpassword.Text; pictureLogin.Source = @"C:\Users\Sergio\Documents\Visual Studio 2008\Projects\emailwpf\emailwpf\ok.png"; }
I get an error:
"Cannot convert string to ImageSource"
.What can I do?
-
Sergio Tapia about 14 yearsAnd if I want to use the "/ok.png" form instead of the long string, how can I do that?
-
Yuriy Zanichkovskyy about 14 yearsjust creating Uri object, and specifying UriKind.Relative