我有一個Silverlight應用程序,我遇到了問題。瀏覽器刷新時Silverlight頁不加載
正常加載時 - 通過網絡瀏覽器或將其安裝到桌面時,頁面工作良好。 問題出現在瀏覽器中,當有人點擊刷新。
當它們點擊刷新(F5)時,沒有數據加載,控件呈現但數據綁定的數據是空的。 他們有一個JavaScript錯誤,它出現在IE的底部。
頁面錯誤細節
消息:未處理的錯誤在 Silverlight應用程序上的 'System.Windows.Data.Binding' 提供值 投擲 異常。 [行:74的位置:57] 在 MS.Internal.XcpImports.MethodEx(IntPtr的 PTR,字符串名稱,CValue [] cvData)
在 MS.Internal.XcpImports.MethodEx(DependencyObject的 OBJ,字符串名稱)在 MS.Internal.XcpImports.DataTemplate_LoadContent(DataTemplate中 模板)在 System.Windows.Controls.DataGridTemplateColumn.GenerateElement(DataGridCell 細胞,對象的DataItem)在 System.Windows.Controls.DataGrid.PopulateCellContent(布爾 isCellEdited,的DataGridColumn dataGridColumn,DataGridRow dataGridRow,DataGridCell dataGridCell)在 System.Windows.Controls.DataGrid.AddNewCellPrivate(DataGridRow 行,列的DataGridColumn)在 System.Windows.Controls.DataGrid.CompleteCellsCollection(DataGridRow dataGridRow)在 System.Windows.Controls.DataGrid.GenerateRow( INT32 rowIndex位置,INT32槽,在 System.Windows.Controls.DataGrid.InsertElementAt(INT32 插槽,INT32 rowIndex位置,對象項目, DataGridRowGroupInfo GROUPINFO, 布爾isCollapsed)對象 的DataContext)在 System.Windows.Controls.DataGrid .InsertRowAt(Int32 rowIndex)at System.Windows.Controls.DataGridDataConnection。 NotifyingDataSource_CollectionChanged(對象 發件人, NotifyCollectionChangedEventArgs E)
在 System.Windows.Data.PagedCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs 參數)在 System.Windows.Data.PagedCollectionView.ProcessAddEvent(對象 addedItem,的Int32 addIndex)在 系統.Windows.Data.PagedCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)at System.Windows.Data.PagedCollectionView。 < .ctor> B_ 0(對象 發件人, NotifyCollectionChangedEventArgs參數) 在 System.Collections.ObjectModel.ObservableCollection在 System.Collections.ObjectModel.Collection`11.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection
1.InsertItem(的Int32 索引,T項)。在 MyProject.Silverlight.MyViewModel.b _3(對象 帕拉姆,GetDataCompletedEventArgs EventArgs的)添加(T 項目)在 MyProject.Silverlight.WebServicesSVC.WebServicesClient。OnGetDataCompleted(對象 狀態)行:1字符:1個代碼:0
如果[行:74的位置:57]是從XAML文件,則誤差是中間行:
<sdk:DataGridTemplateColumn Header="Edit Details">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Command="{Binding UpdateCommand, Source={StaticResource ViewModel}}" CommandParameter="{Binding}" Content="Update" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
即,[Button ...]行,位置57是「{Binding ..}」在Command =中開始的位置。
- 正如我所說,這隻發生在頁面刷新使用IE的刷新按鈕時,並且它發生在每臺PC上。
其他細節: 的Internet Explorer 8 客戶端電腦:Windows XP中 託管服務器:在Windows Server 2005(或2003,如果沒有這樣的東西作爲2005年)。 Silverlight 4
任何人都可以闡明什麼是錯的?如何處理刷新與正常加載頁面不同?
刷新頁面比第一次加載更快,因此它可能是一個計時問題。你的數據來自哪裏?它是如何填充的? – 2011-06-14 15:52:35
@jb我寫了一個非常小的HelloWorld,看它是否是Silverlight正在做的特殊事情,事實並非如此。 F5確實能夠正確地提供我的數據。是否有可能分享一些代碼,以便我可以嘗試重現該問題? – Nair 2011-06-14 17:59:03
該頁面由幾個WCF服務填充;我在應用程序中有幾個頁面,只有其中一個失敗(那個確實有4-5個服務調用將數據拉回的頁面)。 – 2011-06-15 15:16:40