问题描述
如何从代码中更改imageSource?
How am I change imageSource from the code?
我写道:
I write:
tbImage
. ImageSource = 新 BitmapImage ( 新 Uri ( @""\ profile \ a.gif" )));
.ImageSource = newBitmapImage(newUri(@"\profile\a.gif"));
,并且它没有变化.
推荐答案
1-添加一个." URI路径开头的字符.
1- Add a '.' character at the start of the URI path.
2-使用'/'代替'\'
2- Use '/' instead of '\'
3-设置"UriKind".到相对"即:tbImage.ImageSource = new BitmapImage(new Uri(@"./profile/a.gif",UriKind.Relative));
3- Set the "UriKind" to "Relative" i.e: tbImage.ImageSource = new BitmapImage(new Uri(@"./profile/a.gif", UriKind.Relative));
请在我的回复中将其标记为已答应"如果有帮助的话.
Please, mark my reply as "Asnwered" if it helped.
这篇关于改变形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!