Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
PaneToolWindow causes binding errors when switching tabs in docked window
posted

When clicking on tabs for docked views, the PaneToolWindow causes a binding error when switching between views.  All the views are docked in either the main window or a floating window.

Using .Net Reflector and tracing thru the code, the PaneToolWindow.RefreshSinglePaneTitle() method causes the binding issue.

internal void RefreshSinglePaneTitle()
{
ContentPane singlePane = this.SinglePane;
if (singlePane == null)
{
base.ClearValue(ToolWindow.TitleProperty);
}
else if (singlePane.Header is TextBlock)
{
base.SetBinding(ToolWindow.TitleProperty, Utilities.CreateBindingObject(TextBlock.TextProperty, BindingMode.OneWay, singlePane.Header));
}
else
{
base.SetBinding(ToolWindow.TitleProperty, Utilities.CreateBindingObject(HeaderedContentControl.HeaderProperty, BindingMode.OneWay, singlePane));
}
}

The highlighted line changes the bindings for which there is no path to the correct endpoint.  After this line is executed, the ActivePaneChanged routed event is fired, which the user code sets the bindings correctly for the PaneToolWindow to display the title in the tab.

It seems there is no way to intercept or override to prevent the binding error and associated internal exceptions caused by this.  Performance is affected by the missing binding when switching between tabs.

It would seem that there needs to be some sort of event to allow user code to correctly set the bindings as the OnSinglePaneToolWindowChanged method clears all of the bindings in the PaneToolWindow when active pane is changed.

private static void OnSinglePaneToolWindowChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ContentPane pane = d as ContentPane;
if (pane != null)
{
PaneToolWindow newValue = e.NewValue as PaneToolWindow;
PaneToolWindow oldValue = e.OldValue as PaneToolWindow;
if (oldValue != null)
{
BindingOperations.ClearBinding(oldValue, ToolWindow.TitleProperty);
}
if (newValue != null)
{
newValue.RefreshSinglePaneTitle();
}
pane.VerifyHeaderVisibility();
}
}

There doesn't seem to be a workable solution for this to eliminate the binding issues thru any other events that would allow the PaneToolWindow to have its bindings reset before the DockingManagement resets the binding to the Content Header?

Maybe adding an event that would allow a PrepareToolWindow that is fired during the switchover processing that would allow the PaneToolWindow to be reset before the binding being set in RefreshSinglePaneTitle() method.  Currently, the only opportunity to correct the binding is after the fact with the ActivePaneChanged event.

Any suggestions or workarounds?

Thanks

Greg Johnson

gjohnson@virtu.com   (Formerly ITG)

Parents Reply Children
No Data