2014-10-30 23 views
0

在我的silverlight應用程序中我發現這個錯誤,當我試圖將itemssource分配給列表框.Error HRESULT E_FAIL has在System.Windows從呼叫被退回到COM組件在我的Silverlight應用程序中,我發現這個錯誤.Error HRESULT E_FAIL已經從調用COM組件返回

在MS.Internal.XcpImports.CheckHResult(UInt32的小時) 在MS.Internal.XcpImports.SetValue(IManagedPeerBase OBJ,的DependencyProperty屬性,布爾b) .DependencyObject.SetValue(的DependencyProperty屬性,布爾b) 在System.Windows.Controls.ItemsControl.ClearContainers(布爾bHostIsReplaced) 在System.Wi ndows.Controls.ItemsControl.ItemsSourceChanged(DependencyObject的d,DependencyPropertyChangedEventArgs E) 在System.Windows.DependencyObject.RaisePropertyChangeNotifications(的DependencyProperty DP,對象的屬性oldValue,對象newValue)以在System.Windows.DependencyObject.UpdateEffectiveValue(的DependencyProperty屬性,EffectiveValueEntry oldEntry,EffectiveValueEntry & newEntry,ValueOperation操作) 在System.Windows.DependencyObject.SetValueInternal(的DependencyProperty DP,對象的值,布爾allowReadOnlySet,布爾isBindingInStyleSetter) 在System.Windows.Controls.ItemsControl.set_ItemsSource(IEnumerable的值) 在HRPMS.MyDesk.ConferenceRoomBooking .AddSourceToListBox() at HRPMS.MyDesk.ConferenceRoomBooking.chkbxC​​CConsultant_Unchecked(Object sender,RoutedEventA RGS E) 在System.Windows.Controls.Primitives.ToggleButton.OnUnchecked(RoutedEventArgs E) 在System.Windows.Controls.Primitives.ToggleButton.OnIsCheckedPropertyChanged(的DependencyObject d,DependencyPropertyChangedEventArgs E) 在System.Windows.DependencyObject.RaisePropertyChangeNotifications(的DependencyProperty DP,對象的屬性oldValue,在System.Windows在System.Windows.DependencyObject.RefreshExpression(的DependencyProperty DP) 在System.Windows.DependencyObject.UpdateEffectiveValue(的DependencyProperty屬性,EffectiveValueEntry oldEntry,EffectiveValueEntry & newEntry,ValueOperation操作) 對象newValue)以 .Data.BindingExpression.SendDataToTarget() at System.Windows.Data.BindingExpression.SourcePropertyChanged(PropertyPathListener se的nDer,PropertyPathChangedEventArgs參數) 在System.Windows.PropertyPathListener.ReconnectPath() 在System.Windows.Data.Debugging.BindingBreakPoint。 <> c__DisplayClass4.b__3()

回答

1

我這十幾次,如果我沒有記錯它通常發生時,有一個ViewTemplate的時刻將被實例化或切換到可視的XAML一個問題(或一個VisualState變化被觸發)。

較好的選擇是:

  • 引用StaticResources無法找到
  • 的VisualState變化和目標不能被發現,或靜態資源不能被發現,或爲DiscreteObjectKeyFrameValue無法翻譯對於最後一點的目標類型

比較這兩個,有這樣往往:

<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="True"/> 

<DiscreteObjectKeyFrame KeyTime="0:0:0"> 
    <DiscreteObjectKeyFrame.Value> 
     <System:Boolean>True</System:Boolean> 
    </DiscreteObjectKeyFrame.Value> 
</DiscreteObjectKeyFrame> 
相關問題