“Cannot convert string to ImageSource.” How can I do this?

前端 未结 7 1547
南旧
南旧 2021-01-13 11:09
private void HeroMouseEnter(object sender, MouseEventArgs e)
    {
        ((Image)sender).Source = GetGlowingImage(((Image)sender).Name);            
    }

    pub         


        
7条回答
  •  -上瘾入骨i
    2021-01-13 11:44

    Something like:

    BitmapImage myBitmapImage = new BitmapImage(new Uri("../../../../Images/folder.png", UriKind.Relative));
    myBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
    Image.Source = myBitmapImage;
    

提交回复
热议问题