通过代码无法正常添加LongListSelector

时间:2011-11-09 13:58:03

标签: silverlight windows-phone-7 longlistselector

我在Silverlight中通过代码添加LongListSelector时遇到问题。这是代码:

PivotItem pi = new PivotItem();
pi.Header = r.Recipe_Title;

LongListSelector lls = new LongListSelector();
lls.Background = new SolidColorBrush(Colors.Transparent);
lls.ItemTemplate = App.Current.Resources["CheckboxShoppingItemTemplate"] as DataTemplate;
lls.ListHeaderTemplate = App.Current.Resources["citiesListHeader"] as DataTemplate;
lls.GroupFooterTemplate = App.Current.Resources["citiesListFooter"] as DataTemplate;
lls.GroupHeaderTemplate = App.Current.Resources["groupHeaderTemplate"] as DataTemplate;
lls.GroupItemTemplate = App.Current.Resources["groupItemTemplate"] as DataTemplate;
lls.ItemsSource = r.Ingredients;
pi.Content = lls;

显示透视标题,但列表不显示。我只看到列表的标题,但没有别的。尽管页脚是正确的,页脚也会丢失(我已经用页脚替换页眉以查看它是否正确,并且确实如此)。

1 个答案:

答案 0 :(得分:0)