This is a migrated thread and some comments may be shown as answers.

Theme Switching

5 Answers 244 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stephane
Top achievements
Rank 1
Stephane asked on 19 Dec 2012, 05:35 PM
Hello, I'm using Q3 WPF components for the framework 4.
I'm currently switching the app theme dynamically by clearing the merged dictionnay re-adding:
"/Telerik.Windows.Themes.ThemName;component/Themes/System.Windows.xaml"
"/Telerik.Windows.Themes.ThemName;component/Themes/System.Controls.xaml"
"/Telerik.Windows.Themes.
ThemName;component/Themes/System.Controls.Docking.xaml"
"/Telerik.Windows.Themes.
ThemName;component/Themes/System.Controls.GridView.xaml"
"/Telerik.Windows.Themes.
ThemName;component/Themes/System.Navigation.xaml"
"/Telerik.Windows.Themes.ThemName;component/Themes/System.Data.xaml"
"/Telerik.Windows.Themes.ThemName;component/Themes/System.Controls.RibbonView.xaml"

I'm working on a new user control which works fine with all themes, but as soon as I switch to Expression Dark I get the following:
System.Windows.Markup.XamlParseException was unhandled
      Message=Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.
      Source=PresentationFramework
      ....     ...
      Message=Cannot find resource named 'TextBoxBorder_Disabled'. 

(Sorry for the lengthy error...) 
I would greatly appreciate any hint...
here's the whole thing:


System.Windows.Markup.XamlParseException was unhandled
  Message=Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.
  Source=PresentationFramework
  LineNumber=0
  LinePosition=0
  StackTrace:
       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.StackPanel.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.StackPanel.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.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 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.Controls.Border.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 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.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)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(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)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at ABC_WPF.Application.Main() in C:\Users\Arie\Documents\Visual Studio 2010\Projects\ABC_WPF\VirtualINV12_WPF\obj\x86\Debug\Application.g.vb:line 74
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       Message=Cannot find resource named 'TextBoxBorder_Disabled'. Resource names are case sensitive.
       Source=PresentationFramework
       StackTrace:
            at System.Windows.StaticResourceExtension.ProvideValueInternal(IServiceProvider serviceProvider, Boolean allowDeferredReference)
            at System.Windows.StaticResourceExtension.ProvideValue(IServiceProvider serviceProvider)
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
       InnerException: 





 

5 Answers, 1 is accepted

Sort by
0
Stephane
Top achievements
Rank 1
answered on 17 Jan 2013, 02:24 PM


I'd really like to find an answer to that.
Each time I switch to ExpressionDark I get a XamlParseExeption:
"Cannot find resource named 'TextBoxBorder_Disabled'. Resource names are case sensitive."

Please any hint?

0
Tina Stancheva
Telerik team
answered on 22 Jan 2013, 12:20 PM
Hello Stephane,

You need to add the resources from the Telerik.Windows.Controls.Input.xaml ResourceDictionary as well - this particular brush is defined in it.

Basically when using implicit styles, you need to make sure that all required styles are included in the application resources. For example, the RadGridView control depends on the
  • Telerik.Windows.Controls.dll
  • Telerik.Windows.Controls.GridView.dll
  • Telerik.Windows.Controls.Input.dll
  • Telerik.Windows.Data.dll
which means that you need to add the following ResourceDictionaries when styling this control:
  • Telerik.Windows.Controls.xaml
  • Telerik.Windows.Controls.GridView.xaml
  • Telerik.Windows.Controls.Input.xaml

Please give this a try and let us know if that helps.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Stephane
Top achievements
Rank 1
answered on 22 Jan 2013, 06:17 PM
Thank you Tina,
I have added the Telerik.Windows.Controls.Input.xaml a while ago. This didn't help.
The whole app works with dynamic theme switching even with expression dark.
Only one WPF usercontrol bugs on load and it does so only With expression Dark.
The control has 99% other rad controls namely a radRibbonView , radWatermark and autocompleteTextboxes, telerik:Labels, RadDatePickers, 3 radGridViews and a scrollViewer. Why would this control get a "Cannot find resource named 'TextBoxBorder_Disabled'" ?
Is any of these control not compatible with "Expression Dark"?



0
Tina Stancheva
Telerik team
answered on 23 Jan 2013, 08:10 AM
Hello Stephane,

This error indicates that the application can't find the 'TextBoxBorder_Disabled' resource but I'm not sure which control/style is causing the issue. This is why I prepared a sample solution to test the scenario you described, but it works as expected on our side. Can you please take a look at it and let me know if it works on your side? Also, if you can modify it to demonstrate the exception, we will be able to further investigate this issue and suggest a solution.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Siddharth
Top achievements
Rank 1
answered on 19 Feb 2013, 10:18 AM
Thanks Tina,
That worked for me.
Tags
General Discussions
Asked by
Stephane
Top achievements
Rank 1
Answers by
Stephane
Top achievements
Rank 1
Tina Stancheva
Telerik team
Siddharth
Top achievements
Rank 1
Share this question
or