我有一個奇怪的錯誤,我不明白。列表框不在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