任何人都可以帮我解决这个问题,我想绑定以下结果。
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;
}
答案 0 :(得分: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>