0

谁能帮我解决这个问题我想绑定以下结果。

 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;

    }
4

1 回答 1

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>
于 2013-04-30T11:06:07.963 回答