Problem loading Ribbon dynamically with Images

Ribbon for WPF Forum

Posted 12 years ago by Luis Camano
Version: 1.0.0346
Platform: .NET 3.0
Environment: Windows XP (32-bit)
Avatar
Product Version: Ribbon v1.0.346
System: .NET 3.0, Windows XP, 32-bit

I need different Ribbon structure for different users. For that reason, I need to construct the Ribbon, but I don't want to create it adding programatically items.
I'm trying to load dinamycally the ribbon, recovering XAML from a file and construct the control in the next way:

//.....ribbonXAML contains a valid Ribbon XAML definition....
object o = DeserializeXaml(ribbonXAML.InnerXml);
this.LayoutRoot.Children.Add((Ribbon)o);
this.LayoutRoot.RegisterName("mainRibbon", (Ribbon)o);


If the Ribbon don't load any image works correctly, but if I try to load an image on a control or in the ApplicationButtonImage the application produce the next exception:


[System.ArgumentOutOfRangeException] = {"The argument is out of range.\r\nParameter name: index"}
en MS.Utility.FrugalObjectList`1.get_Item(Int32 index)
en System.Windows.Freezable.GetChangeHandlersAndInvalidateSubProperties(EventStorage& calledHandlers)
en System.Windows.Freezable.FireChanged()
en System.Windows.Freezable.WritePostscript()
en System.Windows.Media.Imaging.BitmapSource.remove_DownloadCompleted(EventHandler value)
en System.Windows.Controls.Image.OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
en System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
en System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
en System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
en System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
en System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
en System.Windows.StyleHelper.InvalidatePropertiesOnTemplateNode(DependencyObject container, FrameworkObject child, Int32 childIndex, FrugalStructList`1& childRecordFromChildIndex, Boolean isDetach, FrameworkElementFactory templateRoot)
en System.Windows.StyleHelper.ClearTemplateChain(HybridDictionary[] instanceData, FrameworkElement feContainer, FrameworkContentElement fceContainer, List`1 templateChain, FrameworkTemplate oldFrameworkTemplate)
en System.Windows.StyleHelper.ClearGeneratedSubTree(HybridDictionary[] instanceData, FrameworkElement feContainer, FrameworkContentElement fceContainer, FrameworkTemplate oldFrameworkTemplate)
en System.Windows.StyleHelper.DoTemplateInvalidations(FrameworkElement feContainer, FrameworkTemplate oldFrameworkTemplate)
en System.Windows.Controls.Control.OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
en System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
en System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
en System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
en System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
en System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
en System.Windows.StyleHelper.InvalidateContainerDependents(DependencyObject container, FrugalStructList`1& exclusionContainerDependents, FrugalStructList`1& oldContainerDependents, FrugalStructList`1& newContainerDependents)
en System.Windows.StyleHelper.DoStyleInvalidations(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle)
en System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, Style& styleCache)
en System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
en System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
en System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
en System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
en System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
en System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
en System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
en System.Windows.FrameworkElement.set_Style(Style value)
en ActiproSoftware.Windows.Controls.Ribbon.Controls.StackPanel.GetStyle()
en ActiproSoftware.Windows.Controls.Ribbon.Controls.ControlBase.UpdateStyles()
en ActiproSoftware.Windows.Controls.Ribbon.Controls.StackPanel.UpdateStyles()
en ActiproSoftware.Windows.Controls.Ribbon.Controls.ControlBase.ActiproSoftware.Windows.Controls.Ribbon.Controls.IRibbonControl.UpdateStyles()
en ActiproSoftware.Windows.Controls.Ribbon.Controls.Group.UpdateStyles()
en ActiproSoftware.Windows.Controls.Ribbon.Controls.Group.b(Boolean A_0)
en ActiproSoftware.Windows.Controls.Ribbon.Controls.Tab.d()
en ActiproSoftware.Windows.Controls.Ribbon.Controls.Tab.f()
en ActiproSoftware.Windows.Controls.Ribbon.Ribbon.c(Object A_0, RoutedEventArgs A_1)
en System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
en System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
en System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
en System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
en MS.Internal.FrameworkObject.OnLoaded(RoutedEventArgs args)
en System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
en System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
en MS.Internal.LoadedOrUnloadedOperation.DoWork()
en System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
en System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
en System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
en System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
en System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
en System.Windows.Interop.HwndTarget.OnResize()
en System.Windows.Interop.HwndTarget.HandleMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
en System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
en MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
en MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
en System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
en System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
en System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
en System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
en MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
en MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
en MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
en MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
en MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
en MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
en MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
en MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
en MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
en MS.Win32.UnsafeNativeMethods.IntCriticalSetWindowLong(HandleRef hWnd, Int32 nIndex, Int32 dwNewLong)
en MS.Win32.UnsafeNativeMethods.CriticalSetWindowLong(HandleRef hWnd, Int32 nIndex, IntPtr dwNewLong)
en System.Windows.Window.Flush()
en System.Windows.Window.HwndStyleManager.System.IDisposable.Dispose()
en System.Windows.Window.OnWindowStyleChanged(WindowStyle windowStyle)
en System.Windows.Window._OnWindowStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
en System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
en System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
en System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
en System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
en System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
en System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
en System.Windows.Window.set_WindowStyle(WindowStyle value)
en a.b(Window A_0)
en ActiproSoftware.Windows.Controls.Ribbon.RibbonWindow.b()
en ActiproSoftware.Windows.Controls.Ribbon.RibbonWindow.OnSourceInitialized(EventArgs e)
en System.Windows.Window.CreateSourceWindowImpl()
en System.Windows.Window.SafeCreateWindow()
en System.Windows.Window.ShowHelper(Object booleanBox)
en System.Windows.Window.Show()
en System.Windows.Window.ShowDialog()


If I try to load only some images (4,5, .... 10) in debugging environment sometimes works.
It sounds like a memory leak or similar.

How can I load the Ribbon from an XAML definition in memory?

Thanks in advance.

Comments (1)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Luis,

First, I noticed you don't have the latest build that came out today. Can you please download that and try it to see if changes in that have resolved this?

If not, can you put together a small sample project that repros the issue and email that over to us so we can debug it to see what is happening? Thanks!


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.