我有一个奇怪的错误,我不明白。列表框不在Windows Phone 7更新
我正在创建一个Windows Phone 7应用程序,我在其中创建包含ListBox的PivotItems。
继承人的代码 -
PivotItems = new ObservableCollection<StatusItem>();
DataTemplate itemTemplate = App.Current.Resources["PivotItemTemplate"] as DataTemplate;
ListBox itemBox = new ListBox();
itemBox.ItemsSource = PivotItems;
itemBox.ItemTemplate = itemTemplate;
CorePivotItem = new PivotItem() { Header = header, Content = itemBox };
现在,当我过我对象添加到PivotItems,从来都没有在UI显示出来。
对不起,我没有说清楚第一次 - 这是DataTemplate中绑定 -
<DataTemplate x:Key="PivotItemTemplate">
<StackPanel >
<Image Source="{Binding URL}" ></Image>
<TextBlock Text="{Binding Text}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
我加入PivotItems到另一个OC被绑定到一个枢轴控件。当我滑过PivotItems时,所有列表都显示正常。基本上我猜测的是OC不会触发ListBox上的刷新。我可以使用BindingExpressions强制刷新列表吗?
是你的项目模板绝对好吗?如果你没有指定它(使用默认的),你会得到*东西*显示出来吗? – 2010-11-05 07:14:52
这是相同的问题,在http://stackoverflow.com/questions/4114608/databound-pivot-control-is-not-creating-the-first-pivotitem – 2010-11-08 12:44:15