Trouble setting Theme at runtime

9 posts, 1 answers
  1. Dan Weese
    Dan Weese avatar
    16 posts
    Member since:
    Sep 2009

    Posted 12 Mar 2010 Link to this post

    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:

     

  2. Pana
    Admin
    Pana avatar
    748 posts

    Posted 16 Mar 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dan Weese
    Dan Weese avatar
    16 posts
    Member since:
    Sep 2009

    Posted 16 Mar 2010 Link to this post

    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.
  5. Answer
    Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 18 Mar 2010 Link to this post

    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.
  6. Hidayet ÇELEN
    Hidayet ÇELEN avatar
    10 posts
    Member since:
    Apr 2010

    Posted 01 Oct 2010 Link to this post

    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
  7. Hidayet ÇELEN
    Hidayet ÇELEN avatar
    10 posts
    Member since:
    Apr 2010

    Posted 01 Oct 2010 Link to this post

    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
  8. Hidayet ÇELEN
    Hidayet ÇELEN avatar
    10 posts
    Member since:
    Apr 2010

    Posted 01 Oct 2010 Link to this post

    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
  9. Hidayet ÇELEN
    Hidayet ÇELEN avatar
    10 posts
    Member since:
    Apr 2010

    Posted 01 Oct 2010 Link to this post

    sorry,

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

    Thanks
  10. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 06 Oct 2010 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready