I have a silverlight application which I am having an issue with.
The page works great when loaded up normally - either through a web browser or when its installed to desktop. The problem comes in the browser, when someone hits refresh.
When they hit refresh (F5) no data is loaded, the controls render but the data-bound ones are empty. And they have a javascript error which appears at the bottom of IE.
Webpage error details
Message: Unhandled Error in Silverlight Application Provide value on 'System.Windows.Data.Binding' threw an exception. [Line: 74 Position: 57] at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
at MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name) at MS.Internal.XcpImports.DataTemplate_LoadContent(DataTemplate template) at System.Windows.Controls.DataGridTemplateColumn.GenerateElement(DataGridCell cell, Object dataItem) at System.Windows.Controls.DataGrid.PopulateCellContent(Boolean isCellEdited, DataGridColumn dataGridColumn, DataGridRow dataGridRow, DataGridCell dataGridCell) at System.Windows.Controls.DataGrid.AddNewCellPrivate(DataGridRow row, DataGridColumn column) at System.Windows.Controls.DataGrid.CompleteCellsCollection(DataGridRow dataGridRow) at System.Windows.Controls.DataGrid.GenerateRow(Int32 rowIndex, Int32 slot, Object dataContext) at System.Windows.Controls.DataGrid.InsertElementAt(Int32 slot, Int32 rowIndex, Object item, DataGridRowGroupInfo groupInfo, Boolean isCollapsed) at System.Windows.Controls.DataGrid.InsertRowAt(Int32 rowIndex) at System.Windows.Controls.DataGridDataConnection.NotifyingDataSource_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) at System.Windows.Data.PagedCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) at System.Windows.Data.PagedCollectionView.ProcessAddEvent(Object addedItem, Int32 addIndex) at System.Windows.Data.PagedCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args) at System.Windows.Data.PagedCollectionView.<.ctor>b_0(Object sender, NotifyCollectionChangedEventArgs args) at System.Collections.ObjectModel.ObservableCollection1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection
1.InsertItem(Int32 index, T item) at System.Collections.ObjectModel.Collection`1.Add(T item) at MyProject.Silverlight.MyViewModel.b_3(Object Param, GetDataCompletedEventArgs EventArgs) at MyProject.Silverlight.WebServicesSVC.WebServicesClient.OnGetDataCompleted(Object state) Line: 1 Char: 1 Code: 0
If the [Line: 74 Position: 57] is from the xaml file, then the error is the middle line of:
<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>
ie, the [Button...] line, position 57 is where the "{Binding..}" starts in the Command=.
-- As I say this only happens when the page is refreshed using IE's refresh button, and it happens every time on multiple PC's.
Additional details: Internet Explorer 8 Client PCs: Windows XP Hosting Server: Windows Server 2005 (or 2003 i开发者_如何学Pythonf there is no such thing as 2005). Silverlight 4
Can anyone shed any light on what is wrong? How is a refresh handled differently from just loading the page normally?
When I get javascript errors in the deployed version of my silverlight project, it almost always is my application's logic problem in the behind code. YMMV.
Given you have SL4, you probably can't place debug point in XAML. I felt like mentioning SL5 beta on a different box with your code deployed to gain that feature to assist in debugging.
Alternatively, you could refresh in software per:
Can Silverlight initiate Page Refreshes?
and then see if your app behaves differently.
精彩评论