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

Trouble setting Theme at runtime

8 Answers 236 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dan Weese
Top achievements
Rank 1
Dan Weese asked on 13 Mar 2010, 04:40 AM
I am trying to change the theme of some of the RadControls at runtime. In the documentation, I found 2 ways to set the theme, neither of which work. I can set the theme at design time no problem.

StyleManager

 

.SetTheme(radSchedulerMain, new Office_BlackTheme());

 

radSchedulerMain.SetValue(

StyleManager.ThemeProperty,new SummerTheme());

 

 

With both methods, I get "There is no source code available for the current location", then "Index was outside the bounds of the array". How do I get past this problem?? Exception details below.


System.IndexOutOfRangeException was unhandled
  Message="Index was outside the bounds of the array."
  Source="PresentationFramework"
  StackTrace:
       at System.Windows.Controls.ItemContainerGenerator.RealizedItemBlock.ContainerAt(Int32 index)
       at System.Windows.Controls.ItemContainerGenerator.ContainerFromIndex(Int32 index)
       at Telerik.Windows.Controls.RadRibbonBar.TabControlElementItemContainerGenerator_StatusChanged(Object sender, EventArgs e) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\RibbonBar\RibbonBar\RadRibbonBar.cs:line 1197
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Controls.ItemContainerGenerator.SetStatus(GeneratorStatus value)
       at System.Windows.Controls.ItemContainerGenerator.Generator.System.IDisposable.Dispose()
       at System.Windows.Controls.Panel.reGenerateChildren()
       at System.Windows.Controls.Panel.get_InternalChildren()
       at Telerik.Windows.Controls.RibbonBar.Primitives.TabStripPanel.MeasureOverride(Size availableSize) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\RibbonBar\RibbonBar\Primitives\TabStripPanel.cs:line 59
       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.ItemsPresenter.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.ScrollContentPresenter.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.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.DockPanel.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 Telerik.Windows.Controls.RadTabControl.MeasureOverride(Size availableSize) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\TabControl\RadTabControl.cs:line 2045
       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 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.ContextLayoutManager.UpdateLayout()
       at Telerik.Windows.Controls.RadComboBox.NavigateToItem(Object item) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\ComboBox\RadComboBox.cs:line 780
       at Telerik.Windows.Controls.RadComboBox.OnSelectionChanged(SelectionChangedEventArgs e) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\ComboBox\RadComboBox.cs:line 1365
       at System.Windows.Controls.Primitives.Selector.SelectionChanger.End()
       at System.Windows.Controls.Primitives.Selector.SelectionChanger.SelectJustThisItem(Object item, Boolean assumeInItemsCollection)
       at System.Windows.Controls.Primitives.Selector.OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.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, OperationType operationType)
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at System.Windows.Controls.Primitives.Selector.set_SelectedItem(Object value)
       at Telerik.Windows.Controls.RadComboBox.NotifyComboBoxItemMouseUp(RadComboBoxItem comboBoxItem) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\ComboBox\RadComboBox.cs:line 870
       at Telerik.Windows.Controls.RadComboBoxItem.OnMouseLeftButtonUp(MouseButtonEventArgs e) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\ComboBox\RadComboBoxItem.cs:line 254
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at System.Windows.Interop.HwndSource.InputFilterMessage(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, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       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.TranslateAndDispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Application.RunInternal(Window window)
       at Scheduler_WPF.App.Main() in C:\Personal Files\My Dropbox\Scheduler_WPF\Scheduler_WPF\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

 

8 Answers, 1 is accepted

Sort by
0
Pana
Telerik team
answered on 16 Mar 2010, 04:21 PM
Hi Dan Weese,

I have absolutely no idea why it fails. I have created example project for you that displays RadScheduler with 3 buttons below that switch scheduler's theme. If you manage to make it crush with your exception please send it back so we can debug it here. I hope the attached project will help you.

Best wishes,
Panayot
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Dan Weese
Top achievements
Rank 1
answered on 16 Mar 2010, 07:48 PM
OK, I got that working on the Scheduler control and the Expander control on my form, but I'm guessing I can't set the theme of the RadRibbonBar from a RadRibbonComboBox contained on the RadRibbonBar?

 

private void OfficeBlue_Selected(object sender, RoutedEventArgs e)

 

{

radSchedulerMain.SetValue(

StyleManager.ThemeProperty, new Office_BlueTheme());

 

radRibbonBar_Main.SetValue(

StyleManager.ThemeProperty, new Office_BlueTheme());

 

radExpanderMain.SetValue(

StyleManager.ThemeProperty, new Office_BlueTheme());

 

}


Throws the same error I reported earlier, but ONLY when setting the theme on the ribbon. If I comment it out, it works fine. It behaves this way using a combo, or buttons like you had in the example.
0
Accepted
Valentin.Stoychev
Telerik team
answered on 18 Mar 2010, 06:34 PM
Hi Dan Weese,

Yes - you are correct - we have tihs issue in ribbon bar currently. we are working on fixing it. You can however use the application theme with ribbon bar, but you can't change it in runtime.

Kind regards,
Valentin.Stoychev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Hidayet ÇELEN
Top achievements
Rank 1
answered on 01 Oct 2010, 06:57 AM
hi,

Is there any change about that issue? I can change RadRibborBar Theme at runtime but buttons on gallery go to invisible.And if I change in xaml statically ( telerik:stylemanager.theme:xxxx) makes same problem, if remove that (telerik:stylemanager.theme:xxx) from line everything  is ok.

Thanks
0
Hidayet ÇELEN
Top achievements
Rank 1
answered on 01 Oct 2010, 07:54 AM
Hi,

I solved my problem.Behind code dynamic theme changes can be seen on radribbon galery when theme changed in ribbonbar(which include ribbon galery) , but buttons can not be seen.

SOLUTION : Independently, change the theme of ribbon galery dynamically also.(if you use static, you must set theme to ribbon galery also, not only ribbon bar).

Thanks
0
Hidayet ÇELEN
Top achievements
Rank 1
answered on 01 Oct 2010, 08:54 AM
Hi,

This is nıot absolutely solved.If I define telerik:stylemanager.theme="Office_Black" in ribbonbar (in xaml), I must define telerik:stylemanager.theme="Office_Black" in Ribbon Galery.If one is Office_Black , other one is Office_Blue(or any other theme differ than Office_Black) Ribbon Galery's buttons are going to invisible.So, theme of Ribbon Galery must be defined and be same with theme of Ribbon Bar , if Ribbon Bar theme is defined.Otherwise , buttons are invisible.

When I want to change theme of Ribbon Bar in code behind (runtime), the buttons of Ribbon Galery are going to invisible.Also, I change the themes of Ribbon Bar and Ribbon Galery at same time and set two's to same theme, but still buttons are invisible.

What's wrong? What's the absolute solution?

Thanks,

Hidayet ÇELEN,TURKEY
Computer Engineer
http://uzmanprogarmcı.com
0
Hidayet ÇELEN
Top achievements
Rank 1
answered on 01 Oct 2010, 08:59 AM
sorry,

screenshots are here.Abnormal is after dynamic change.Normal is inital state of window.

Thanks
0
Tina Stancheva
Telerik team
answered on 06 Oct 2010, 08:30 AM
Hi Hidayet ÇELEN,

We posted an answer to the support ticket you opened by I will paste it here as well, if anyone else should encounter the same issue.

This issue is logged in our PITS where you can track it. In the meantime you can workaround it using the approach illustrated in the attached example.

Best wishes,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Dan Weese
Top achievements
Rank 1
Answers by
Pana
Telerik team
Dan Weese
Top achievements
Rank 1
Valentin.Stoychev
Telerik team
Hidayet ÇELEN
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or