我的代码:绑定UriSource对BitmapImage的工作不
<Image Height="100" Width="100" HorizontalAlignment="Left" VerticalAlignment="Top">
<Image.Source>
<BitmapImage DecodePixelWidth="100">
<BitmapImage.UriSource>
<PriorityBinding>
<Binding Path="MyModel1.ImagePath"/>
<Binding Path="MyModel2.ImagePath"/>
</PriorityBinding>
</BitmapImage.UriSource>
</BitmapImage>
</Image.Source>
</Image>
在我的视图模型,ImagePath的值:
public object ImagePath
{
get { return new Uri("F:/myFolder/default.png", UriKind.Absolute); }
}
的路径F:/myFolder/default.png存在。我得到错误:必须设置属性'UriSource'或属性'StreamSource'。这是为什么发生?我在哪里犯错误?
回报新 “F:/myFolder/default.png”;返回错误:预期类型。 – 2014-11-24 14:35:46
我必须使用BitmapImage,因为我想使用DecodePixelWidth属性。 – 2014-11-24 14:40:00
对不起,该属性应该是'string' ...复制和粘贴错误。我现在更新了它。 – Sheridan 2014-11-24 15:16:10