2013-04-30 62 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