2012-06-05 34 views
0

我有一个WPF应用程序,我在其中修改了许多控件的模板。在许多不同的情况下,我得到了以下堆栈跟踪:System.Windows.Media.SolidColorBrush必须将IsFrozen设置为False才能编辑错误

Specified value of type 'System.Windows.Media.SolidColorBrush' must have IsFrozen set to false to modify. 
Specified value of type 'System.Windows.Media.SolidColorBrush' must have IsFrozen set to false to modify. (Exception class InvalidOperationException) 

    at System.Windows.Markup.XamlReader.RewrapException(Exception e, Uri baseUri) 
    at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter) 
    at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter) 
    at System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField) 
    at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren) 
    at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate) 
    at System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1 templateDataField, FrameworkElement container) 
    at System.Windows.FrameworkElement.ApplyTemplate() 
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize) 
    at System.Windows.UIElement.Measure(Size availableSize) 
    at System.Windows.Controls.Border.MeasureOverride(Size constraint) 
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize) 
    at System.Windows.UIElement.Measure(Size availableSize) 
    at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV) 
    at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV) 
    at System.Windows.Controls.Grid.MeasureOverride(Size constraint) 
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize) 
    at System.Windows.UIElement.Measure(Size availableSize) 
    at System.Windows.Controls.Control.MeasureOverride(Size constraint) 
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize) 
    at System.Windows.UIElement.Measure(Size availableSize) 
    at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV) 
    at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV) 
    at System.Windows.Controls.Grid.MeasureOverride(Size constraint) 
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize) 
    at System.Windows.UIElement.Measure(Size availableSize) 
    at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint) 
    at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint) 
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize) 
    at System.Windows.UIElement.Measure(Size availableSize) 
    at System.Windows.ContextLayoutManager.UpdateLayout() 
    at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg) 
    at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork() 
    at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 
    at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) 
    at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) 
    at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget) 
    at System.Windows.Interop.HwndTarget.OnResize() 
    at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam) 
    at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
    at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 
    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) 

我没有写任何试图改变任何画笔的瓦莱斯任何代码。我不知道哪个控件产生错误。我怀疑问题出在我修改的模板之一中,但我不知道哪一个。

我不知道如何跟踪和调试它。有人有想法吗?

+0

讨厌!我不明确如何解决你的问题,但面对这种情况,我可能会改变Debug |例外|抛出CLR异常,然后在IDE中运行该应用程序,并在异常命中时查看汽车和本地人以尝试确定违规模板是什么。 –

回答

0

我很幸运,在这一个。

我注意到错误发生在应用程序的两个不同的屏幕上。他们唯一的共同点就是Telerik的RadGridView控制。我已经对此控件进行了一些自定义修改,以支持将颜色托盘从“白天模式”更改为“夜间模式”。

我不知道我做了什么,但是我从app.xaml文件中删除了自定义模板,错误消失了。然后,我在Expression Blend中重新生成了模板,只替换了我所做颜色更改的Setters。而错误仍然消失!

我怀疑我可能在实施“夜间模式”的过程中升级了Telerik库,并且我有一个用于控件的过时模板。无论如何,这个错误已经消失了,至少现在是这样。

相关问题