2011-06-10 89 views
6

我有一個DataGrid(silverlight 4)的特定視圖。但是我有一個項目,資源已經與另一個項目合併(用於後援)。現在,合併後,我收到這個錯誤,每當我嘗試添加一個新的行對象到我的ObservableCollection ....我的理論是,這是xaml(我可以觸摸!)的錯誤,或者,希望,合併資源(風格&畫筆)。這通常意味着什麼,錯誤HRESULT E_FAIL已從調用COM組件返回。

MS.Internal.WrappedException was unhandled by user code 
    Message=Error HRESULT E_FAIL has been returned from a call to a COM component. 
    StackTrace: 
     at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 
     at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize) 
     at System.Windows.UIElement.Measure(Size availableSize) 
     at System.Windows.Controls.DataGrid.InsertDisplayedElement(Int32 slot, UIElement element, Boolean wasNewlyAdded, Boolean updateSlotInformation) 
     at System.Windows.Controls.DataGrid.OnAddedElement_Phase1(Int32 slot, UIElement element) 
     at System.Windows.Controls.DataGrid.OnInsertedElement_Phase1(Int32 slot, UIElement element, Boolean isCollapsed, Boolean isRow) 
     at System.Windows.Controls.DataGrid.InsertElement(Int32 slot, UIElement element, Boolean updateVerticalScrollBarOnly, Boolean isCollapsed, Boolean isRow) 
     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.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) 
     at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item) 
     at System.Collections.ObjectModel.Collection`1.Add(T item) 
InnerException: 
     Message=Error HRESULT E_FAIL has been returned from a call to a COM component. 
     StackTrace: 
      at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 
      at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize) 
      at System.Windows.FrameworkElement.MeasureOverride(Size availableSize) 
      at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight) 
     InnerException: 
+0

聽起來就像你找到了一個真正的bug。嘗試創建一個儘可能簡單的項目來重現問題。使用Microsoft的Connect網站進行報告。你也可以考慮在微軟自己的silverlight論壇上重複這個問題,那裏的MSFT支持chappies更加活躍。 – AnthonyWJones 2011-06-11 17:27:48

回答

20

這通常意味着您的XAML有一個問題,在設計時無法驗證,但會在運行時顯示。鑑於你的情況,我猜你正在添加的行可能會導致Datagrid列模板之一以這種方式出錯。

這通常是由於對不存在或不在XAML上下文中的樣式或事件處理程序的引用。根據我的經驗,這是自定義控件開發中常見的情況。

查看我對類似問題的回答here

HTH。

+0

鏈接不再起作用,或許是另一種鏈接到它的方式? – NotAGenie 2016-07-20 21:16:26

相關問題