【发布时间】:2010-08-06 19:22:30
【问题描述】:
我将 ListView 绑定到对象列表,就像这样;
<ListView
ItemsSource="{ Binding Path=. }"
ItemTemplate="{DynamicResource EventTemplate}">
我正在绑定一个声明两个属性的对象;
string DisplayName { get; }
System.Drawing.Image Image { get; set; }
我想填充DataTemplate,但我不知道怎么做;如果我在我的模板中这样做;
<StackPanel Orientation="Horizontal">
<Image Source="{ Binding Path=Image }" />
<TextBlock Text="{ Binding Path=DisplayName }" />
</StackPanel>
文字出现,但图像不出现。我究竟做错了什么?调试输出显示
System.Windows.Data Error: 1 : Cannot create default converter
to perform 'one-way' conversions between types
'System.Drawing.Image' and 'System.Windows.Media.ImageSource'.
Consider using Converter property of Binding.
BindingExpression:Path=Image; DataItem='RealElement'
(HashCode=54308798); target element is 'Image' (Name='');
target property is 'Source' (type 'ImageSource')
【问题讨论】: