Silverlight 五 Expander中的ListBox绑定数据后就是不显示(本人已痛不欲生)
Silverlight 5 Expander中的ListBox绑定数据后就是不显示(本人已痛不欲生)
我用的是WCF Data Service
我有两个表对象,一个是产品类型(ProductType),一个是产品(Product),有外键关联
XMAL结构是ListBox->Expander->ListBox
Expander绑定的是ProductType,
EXpander的ContentTemplate中用的是ListBox,
意思是每个产品类型下的产品。
在我LoadProperty后,我将数据绑定在Expander下的ListBox中,Expander数据绑定(ProductType)没问题,但是ListBox里(Product)始终不显示数据,就是不显示啊不显示,我已经搞了3天了,我的痛啊
我是业余的求专业的大哥帮我打开心结
App.xaml代码:
<Application.Resources>
<DataTemplate x:Key="listboxexpander" >
<Grid>
<toolkit:Expander Header="{Binding Path=ProductTypeName}" >
<toolkit:Expander.ContentTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding Products}" DataContext="{Binding Products}" DisplayMemberPath="ProductName"/>
</DataTemplate>
</toolkit:Expander.ContentTemplate>
</toolkit:Expander>
</Grid>
</DataTemplate>
</Application.Resources>
MainPage.Xaml代码:
<Grid>
<ListBox Name="expandpanel" ItemTemplate="{StaticResource listboxexpander}" >
</ListBox>
</Grid>
------解决方案--------------------
list中放list我做过,是可以的,但你这种测试方式有问题吧,数据一定没有问题,问题可能出现在你里面的list根本就没有获取到需要绑定的数据{Binding Products}
------解决方案--------------------
<DataTemplate x:Key="listboxexpander" >
<Grid>
<toolkit:Expander Header="{Binding Path=ProductTypeName}">
<toolkit:Expander.Content>
<ListBox ItemsSource="{Binding Productes}" DisplayMemberPath="ProductName"/>
</toolkit:Expander.Content>
我用的是WCF Data Service
我有两个表对象,一个是产品类型(ProductType),一个是产品(Product),有外键关联
XMAL结构是ListBox->Expander->ListBox
Expander绑定的是ProductType,
EXpander的ContentTemplate中用的是ListBox,
意思是每个产品类型下的产品。
在我LoadProperty后,我将数据绑定在Expander下的ListBox中,Expander数据绑定(ProductType)没问题,但是ListBox里(Product)始终不显示数据,就是不显示啊不显示,我已经搞了3天了,我的痛啊
我是业余的求专业的大哥帮我打开心结
App.xaml代码:
<Application.Resources>
<DataTemplate x:Key="listboxexpander" >
<Grid>
<toolkit:Expander Header="{Binding Path=ProductTypeName}" >
<toolkit:Expander.ContentTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding Products}" DataContext="{Binding Products}" DisplayMemberPath="ProductName"/>
</DataTemplate>
</toolkit:Expander.ContentTemplate>
</toolkit:Expander>
</Grid>
</DataTemplate>
</Application.Resources>
MainPage.Xaml代码:
<Grid>
<ListBox Name="expandpanel" ItemTemplate="{StaticResource listboxexpander}" >
</ListBox>
</Grid>
silverlight
------解决方案--------------------
list中放list我做过,是可以的,但你这种测试方式有问题吧,数据一定没有问题,问题可能出现在你里面的list根本就没有获取到需要绑定的数据{Binding Products}
------解决方案--------------------
<DataTemplate x:Key="listboxexpander" >
<Grid>
<toolkit:Expander Header="{Binding Path=ProductTypeName}">
<toolkit:Expander.Content>
<ListBox ItemsSource="{Binding Productes}" DisplayMemberPath="ProductName"/>
</toolkit:Expander.Content>