我有这样的对象:WPF绑定问题
class a
{
public string Application;
public DateTime From, To;
}
而且我宣布这个名单吧:
ObservableCollection<a> ApplicationsCollection =
new ObservableCollection<a>();
在我的XAML我:
<ListView Height="226.381" Name="lstStatus" Width="248.383" HorizontalAlignment="Left" Margin="12,0,0,12" VerticalAlignment=">
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="Application"
DisplayMemberBinding="{Binding Path=Application}"/>
<GridViewColumn Width="50" Header="From"
DisplayMemberBinding="{Binding Path=From}"/>
<GridViewColumn Width="50" Header="To"
DisplayMemberBinding="{Binding Path=To}"/>
</GridView>
</ListView.View>
</ListView>
当我这样做:
lstStatus.ItemsSource = ApplicationsCollection;
我收到了一堆错误,并没有在我的列表视图中显示出来:
System.Windows.Data Error: 39 : BindingExpression path error: 'Application' property not found on 'object' ''a' (HashCode=60325168)'. BindingExpression:Path=Application; DataItem='a' (HashCode=60325168); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 39 : BindingExpression path error: 'From' property not found on 'object' ''a' (HashCode=60325168)'. BindingExpression:Path=From; DataItem='a' (HashCode=60325168); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 39 : BindingExpression path error: 'To' property not found on 'object' ''a' (HashCode=60325168)'. BindingExpression:Path=To; DataItem='a' (HashCode=60325168); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
这显然看到物体具有类型a
和显然有正确的性质,为什么不是这方面的工作?
哇,这让我疯狂,谢谢一堆! – Blindy 2009-10-25 10:10:16