我正在使用SL5withWCF来填充我Listbox的数据。该WCF方法返回 a List(Of Unit),我试图将其转换为List(Of MyService.Unit)客户端上的 a 。当我调试时,我可以看到lsbItems.SelectedItemscount > 0 但它不会转换,我的变量是Nothing. 这Listbox是网格内部 -grdItems我在这里缺少什么?
在 XAML 中:
<ListBox ItemsSource="{Binding}" Name="lsbItems">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Description}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
使用 WCF 异步方法绑定:
grdItems.DataContext = e.Result
兑换:
Dim units = TryCast(lsbItems.SelectedItems, List(Of MyService.Unit))