When using an INotifyCollectionChanged (like ObservableCollection<T>), RadDocking subscribes to its CollectionChanged event. This happens on PropertyChanged of the PaneSource property.
It seems that WPF re-intializes the application when you connect to a running remote desktop session or switch the user to a session where the corresponding WPF app is already opened. This triggers the PropertyChanged event again, which subscribes to the PaneSource collection again.
If you connect to the session multiple times, the CollectionChanged handler will be attached multiple times leading to a memory leak.
To work this around, you can manually unsubscribe from the CollectionChanged event when multiple handlers are added.
public class CustomDocking : RadDocking
{
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property.Name == nameof(PanesSource) && PanesSource is INotifyCollectionChanged observableCollection)
{
UnsubscribeCollectionChanged(observableCollection, this);
}
}
public static void UnsubscribeCollectionChanged(INotifyCollectionChanged collection, object dockingInstance)
{
var handlerMethod = typeof(RadDocking).GetMethod("OnPanesSourceCollectionChanged", BindingFlags.NonPublic | BindingFlags.Instance);
var handlerDelegate = Delegate.CreateDelegate(typeof(NotifyCollectionChangedEventHandler), dockingInstance, handlerMethod);
var field = collection.GetType().GetField("CollectionChanged", BindingFlags.Instance | BindingFlags.NonPublic);
var eventDelegate = (MulticastDelegate)field.GetValue(collection);
var handlers = eventDelegate?.GetInvocationList().Where(d => d.Method == handlerMethod);
bool shouldRemoveHandler = handlers.Count() > 1;
if (shouldRemoveHandler)
{
typeof(INotifyCollectionChanged)
.GetEvent("CollectionChanged")
?.RemoveMethod
?.Invoke(collection, new object[] { handlerDelegate });
}
}
}
I need a behaior for RadPane like this:
When we have onl one RadPane, then show headr with a full RadPane group width (Which can be achived using PaneHeader)
In opposite - use regular tab style
Also if I undock RadPane to ToolWindow and I have only single item, I want to completely hide tabs/headers
All this should work for Top TabStripPlacement
Currently Minimize\Restore\Maximize buttons are not shown in the ToolWindow's header, so there are some inconveniences in use. For example, it's impossible to minimize tool windows easily.
Currently when ScaleTransform is used ether on the RadDocking control or its container the compasses/drop cues which are shown when docking a RadPane instance have incorrect scaling and are placed incorrectly. By design the control's scaling is determined by the scaling of the OS environment.
Hi,
In most docking applications (Telerik WinForms, Visual Studio), it is possible to right click on the pane-tab header and get the options:
- New Horizontal Tab Group
- New Vertical Tab Group
- Move to Next Tab Group
etc.
This would nice in WPF as well
/Brian