views:

148

answers:

2
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?

+2  A: 

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;

Yurec
And if I want to use the "/ok.png" form instead of the long string, how can I do that?
Sergio Tapia
just creating Uri object, and specifying UriKind.Relative
Yurec
A: 

This has been asked in another question and has several different ways you can do this.

Link

Alex