WPF ListView 数据绑定
<ListView Height="264" HorizontalAlignment="Left" Margin="28,84,0,0" Name="listView1" VerticalAlignment="Top" Width="526" >
<ListView.View>
<GridView x:Name="gridView1">
<GridViewColumn Header="UserId" DisplayMemberBinding="{Binding Path=UserId}"></GridViewColumn>
<GridViewColumn Header="UserName" DisplayMemberBinding="{Binding Path=UserName}"></GridViewColumn>
<GridViewColumn Header="MobilePhone" DisplayMemberBinding="{Binding Path=MobilePhone}"></GridViewColumn>
<GridViewColumn Header="Address" DisplayMemberBinding="{Binding Path=Address}"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
private void cbUserCategory_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
UserRole_dc userRole = (UserRole_dc)this.cbUserCategory.SelectedItem;
if (userRole != null)
{
UserInfo_dcCollection collection = service.GetUserByRoleId(userRole.Id);
if (collection != null && collection.Count > 0)
{
this.listView1.ItemsSource = collection;
}
}
}