Completed
Last Updated: 31 May 2022 06:18 by ADMIN
Release LIB 2022.2.530 (30 May 2022)
Martin Ivanov
Created on: 05 May 2022 13:08
Category: RibbonView
Type: Bug Report
1
RibbonView: Memory leak occurs when the control is hosted in TabItem and then removed

If you add the RibbonView into the Content of a TabItem (or RadTabItem) and then remove it from the content, the RibbonView is still in the memory. 

This happens because we subscribe to few events of the Parent window on Loaded and unsubscribe on Unloaded. However, because of the specific content loading behavior of TabControl, Loaded of the content (the RibbonView) is fired once and Unloaded only once.

To work this around, before removing the RibbonView from the TabItem, call its OnUnloaded event handler. To do this, you can use a reflection to get the handler and then invoke it.

var methodInfo = typeof(RadRibbonView).GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Where(m => m.Name == "OnUnloaded").First();
methodInfo.Invoke(ribbon, new object[2] { null, null });

0 comments