0

看看就好,没有任何意义:

在此处输入图像描述

对象是在本地创建的,没有外部依赖项。怎么会这样?

(这里创建的类型是Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid

这是堆栈跟踪:

at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.SystemResources.FindCachedResource(Object key, Object& resource, Boolean mustReturnDeferredResourceReference)
at System.Windows.SystemResources.FindResourceInternal(Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
at System.Windows.FrameworkElement.FindResourceInternal(FrameworkElement fe, FrameworkContentElement fce, DependencyProperty dp, Object resourceKey, Object unlinkedParent, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, DependencyObject boundaryElement, Boolean isImplicitStyleLookup, Object& source)
at System.Windows.FrameworkElement.FindResource(Object resourceKey)
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.UpdateContainerHelper()
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.OnSelectedObjectChanged(Object oldValue, Object newValue)
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.OnSelectedObjectChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.set_SelectedObject(Object value)
at GuiHelpers.Dialogs.PropertiesDialog.<>c__DisplayClass11.<Show>b__d() in c:\projects\pro\GuiHelpers\Dialogs\PropertiesDialog.cs:line 44
4

1 回答 1

0

如果使用 UI 线程的调度程序执行一些初始化,您应该能够使用类似的东西:

System.Windows.Application.Current.Dispatcher.Invoke(
    System.Windows.Threading.DispatcherPriority.Normal,
    (System.Action)delegate()
    {
         tempPropertyGrid.SelectedObject = new object();
    });

我不确定这是否能解决您的问题,但值得一试。

于 2015-03-24T12:35:24.817 回答