2013-04-30 61 views
0

任何人都可以帮我解决这个问题,我想绑定以下结果。从代码绑定.sdf查询到列表框

public IList<bankingCategory> bankingInfo() 
    { 
     IList<bankingCategory> bankList = null; 
     using (dataContext context = new dataContext(globalInfo.strConnectionString)) 
     { 
      IQueryable<bankingCategory> query = from c in context.bankcategorees select c; 
      bankList = query.ToList(); 

     } 

     return bankList; 

    } 

回答

1

设置项目源背后

MyListBox.ItemsSource =bankingInfo(); 

您需要设置自定义列表框模板类似下面

<Grid> 
    <ListBox Name="MyListBox"> 
     <ListBox.ItemTemplate> 
      <DataTemplate> 
       <StackPanel Orientation="Horizontal"> 
        <TextBlock Text="{Binding Path=Property1}"></TextBlock> 
        <TextBlock Text="{Binding Path=Property2}"></TextBlock> 
       </StackPanel> 
      </DataTemplate>    
     </ListBox.ItemTemplate> 
    </ListBox> 
</Grid> 
+0

它的工作,但如果我想使用来自不同的多个IList的是什么表? – jamdownian 2013-04-30 11:08:38