开发者

Setting an image.Source from a resource file

开发者 https://www.devze.com 2022-12-18 06:58 出处:网络
privat开发者_运维技巧e void SetCredentials() { username = txtfromEmail.Text; password = txtpassword.Text;
privat开发者_运维技巧e 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?


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;

0

精彩评论

暂无评论...
验证码 换一张
取 消