Я создал модель базового представления, чтобы поместить в нее все общие свойства для всех моих моделей представления, и она реализуется всеми моделями представлений моего приложения C # Silverlight.
Моя модель базового представления также реализуетINotifyPropertyChanged
интерфейс для всех моделей представлений.
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
Когда я часто вызываю событие PropertyChanged
, я получаю сообщение об ошибке:
Error HRESULT E_FAIL has been returned from a call to a COM component.
Трассировка стека
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isBindingInStyleSetter)
at System.Windows.Controls.Control.set_DefaultStyleKey(Object value)
at System.Windows.Controls.ContentControl..ctor()
at MS.Internal.CoreTypes.GetCoreWrapper(UInt32 typeId)
at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference)
at MS.Internal.XcpImports.ConvertDO(IntPtr doPointer, Int32 typeIndex, Boolean releaseObjectReference)
at MS.Internal.XcpImports.ConvertType(CValue outVal, Int32 typeIndex, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)
at MS.Internal.XcpImports.ConvertCValueForManagedWithType(Type propertyType, CValue& outVal, Int32 outDOType, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)
at MS.Internal.XcpImports.GetValue(IManagedPeerBase managedPeer, DependencyProperty property)
at System.Windows.DependencyObject.GetValueInternal(DependencyProperty dp)
at System.Windows.FrameworkElement.GetValueInternal(DependencyProperty dp)
at System.Windows.FrameworkElement.get_Parent()
at Telerik.Windows.RadRoutedEventHelper.FindParent(FrameworkElement item)
at Telerik.Windows.RadRoutedEventHelper.BuildRoute(DependencyObject element, EventRoute route, RadRoutedEventArgs args)
at Telerik.Windows.RadRoutedEventHelper.RaiseEvent(DependencyObject element, RadRoutedEventArgs args)
at Telerik.Windows.DependencyObjectExtensions.RaiseEvent(DependencyObject element, RadRoutedEventArgs e)
at Telerik.Windows.Controls.Selector.OnSelectionChanged(SelectionChangedEventArgs e)
at Telerik.Windows.Controls.RadComboBox.OnSelectionChanged(SelectionChangedEventArgs e)
at Telerik.Windows.Controls.Selector.OnSelectionChanged(Object sender, SelectionChangedEventArgs e)
at Telerik.Windows.Controls.Selector.SelectionChanger`1.InvokeSelectionChangedEvent()
at Telerik.Windows.Controls.Selector.SelectionChanger`1.End()
at Telerik.Windows.Controls.Selector.SelectionChanger`1.SelectJustThisItem(T item)
at Telerik.Windows.Controls.Selector.SelectItemWithValue(Object value)
at Telerik.Windows.Controls.Selector.CoerceSelectedValue(Object value)
at Telerik.Windows.Controls.Selector.OnCoerceSelectedValue(DependencyObject sender, Object newValue)
at Telerik.Windows.PropertyMetadata.DoCoercion(Func`3 areValuesEqual, DependencyObject d, DependencyProperty dp, CoerceValueCallback coerceCallback, Object defaultBaseValue, Boolean forceNewBaseValue, Boolean& isReentrantImplicitCoercion)
at Telerik.Windows.PropertyMetadata.PropertyChangeHook.OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
at System.Windows.Data.BindingExpression.SendDataToTarget()
at System.Windows.Data.BindingExpression.SourceAcquired()
at System.Windows.Data.Debugging.BindingBreakPoint.<>c__DisplayClass4.<BreakOnSharedType>b__3()