Sergio Tapia
Sergio Tapia

Reputation: 41128

Setting an image.Source from a resource file

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?

Upvotes: 6

Views: 15730

Answers (1)

Yuriy Zanichkovskyy
Yuriy Zanichkovskyy

Reputation: 1699

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;

Upvotes: 7

Related Questions