数据绑定-刷新浏览器时不会加载Silverlight页面



我有一个silverlight应用程序,遇到问题。

该页面在正常加载时运行良好——无论是通过网络浏览器还是安装到桌面。当有人点击刷新时,问题出现在浏览器中。

当它们达到刷新(F5)时,不会加载任何数据,控件将渲染,但数据绑定控件为空。他们有一个javascript错误,出现在IE的底部。

网页错误详细信息

消息:中出现未处理的错误Silverlight应用程序提供价值在"System.Windows.Data.Binding"上引发一个例外。[行:74位置:57]在MS.Internal.XcpImports.MethodEx(IntPtrptr,字符串名称,CValue[]cvData)
在MS.Internal.XcpImports.MethodEx(DependencyObjectobj,字符串名称)MS.Internal.XcpImports.DataTemplate_LoadContent(数据模板模板)System.Windows.Controls.DataGridTemplateColumn.GenerateElement(DataGridCell单元格,Object dataItem)System.Windows.Controls.DataGrid.PopulateCellContent(布尔值isCellEdited,DataGridColumndataGridColumn,DataGridRowdataGridRow,DataGridCelldataGridCell)System.Windows.Controls.DataGrid.AddNewCellPrivate(DataGridRow行,DataGridColumn列)System.Windows.Controls.DataGrid.CompleteCellsCollection(DataGridRowdataGridRow)System.Windows.Controls.DataGrid.GenerateRow(Int32rowIndex,Int32插槽,对象dataContext)System.Windows.Controls.DataGrid.InsertElementAt(Int32slot,Int32 rowIndex,Object项,DataGridRowGroupInfo组信息,布尔值isCollapsed)System.Windows.Controls.DataGrid.InsertRowAt(Int32rowIndex)System.Windows.Controls.DataGridDataConnection.NotifyingDataSource_CollectionChanged(对象发送器,NotifyCollectionChangedEventArgs e)
在System.Windows.Data.PagedCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgsargs)System.Windows.Data.PagedCollectionView.ProcessAddEvent(对象addedItem,Int32 addIndex)System.Windows.Data.PagedCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgsargs)System.Windows.Data.PagedCollectionView.<。ctor>b_0(对象发送器,NotifyCollectionChangedEventArgs参数)在System.Collections.ObjectModel.ObservableCollection 1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection 1.插入项(Int32索引,T项)System.Collections.ObjectModel.Collection`1.Add(T项)MyProject.Silveright.MyViewModel.b_3(对象参数,GetDataCompletedEventArgsEventArgs)MyProject.SSilverlight.WebServicesSVC.WebServicesClient.OnGetDataCompleted(对象state)行:1字符:1代码:0

如果[Line:74 Position: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是Command=中"{Binding..}"开始的位置。

--正如我所说,只有当使用IE的刷新按钮刷新页面时才会发生这种情况,而且每次都会在多台电脑上发生。

其他详细信息:Internet Explorer 8客户端电脑:Windows XP主机服务器:Windows Server 2005(如果没有2005,则为2003)。Silverlight 4

有人能说明出了什么问题吗?刷新与正常加载页面的处理方式有何不同?

当我在silverlight项目的部署版本中遇到javascript错误时,代码背后几乎总是我的应用程序的逻辑问题。YMMV。

假设您有SL4,您可能无法在XAML中放置调试点。我想在另一个盒子上提到SL5测试版,部署您的代码以获得该功能,从而帮助调试。

或者,您可以根据以下内容刷新软件:

Silverlight可以启动页面刷新吗?

然后看看你的应用程序是否有不同的表现。

最新更新