Ton*_*ion 18 c# wpf binding listview
我有以下列表视图,但它不显示实际记录,而只显示对象的命名空间.我想知道是否需要在XAML中创建列以显示记录,然后将其绑定到对象的某些属性或者这有什么问题?
<ListView
Name="ListCustomers"
ItemsSource="{Binding Path=ListOfCustomers}"
SelectedItem="{Binding Path=SelectedCustomer}"
SelectionMode="Single"
IsSynchronizedWithCurrentItem="True"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
MinHeight="100"
></ListView>
Run Code Online (Sandbox Code Playgroud)
ListOfCustomers
是一种ObservableCollection<Customer>
类型.实际客户会加载到ObservableCollection中,但不会显示它们.缺什么?
Chr*_*isF 40
您还需要选择要显示的列:
<ListView ItemsSource="{Binding ListOfCustomers}"
SelectedItem="{Binding Path=SelectedCustomer}"
....>
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="First Name"
DisplayMemberBinding="{Binding FirstName}" />
<GridViewColumn Width="140" Header="Last Name"
DisplayMemberBinding="{Binding LastName}" />
<GridViewColumn Width="140" Header="Email Address"
DisplayMemberBinding="{Binding Email}" />
....
</GridView>
</ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
88405 次 |
最近记录: |