图像源绑定不显示任何内容 [英] Image Source Binding not display anything
本文介绍了图像源绑定不显示任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样一张图片:
<Image Height="32" Width="32" Source="{Binding MatchController.Match.TeamHomeShield}" IsEnabled="False" />
和一个标签:
<Label Content="{Binding MatchController.Match.TeamHomeShield}" />
我的问题是在Image上看不到图片,但是在label上可以看到TeamHomeShield
的值,属性是这样创建的:
my problem's that I can't get the image displayed on the Image, but on the label I can see the value of TeamHomeShield
, the property is created in this way:
private string _teamHomeShield;
public string TeamHomeShield
{
get { return _teamHomeShield; }
set
{
_teamHomeShield = value;
OnPropertyChanged();
}
}
private string _teamAwayShield;
public string TeamAwayShield
{
get { return _teamAwayShield; }
set
{
_teamAwayShield = value;
OnPropertyChanged();
}
}
为什么会这样?
推荐答案
您可以使用 ImageSource 属性(不是字符串)正确绑定图像.
You can use ImageSource property (not string) for binding images correctly.
例如:
public ImageSource ImagePath { get; set; }
这篇关于图像源绑定不显示任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文