Hello,
We inherited ToolWindow and added features to automatically hide TitleBar.
public class CustomToolWindow : ToolWindow
{
public bool UseAutoHideTitleBar
{
get { return (bool)GetValue(UseAutoHideTitleBarProperty); }
set { SetValue(UseAutoHideTitleBarProperty, value); }
}
public static readonly DependencyProperty UseAutoHideTitleBarProperty =
DependencyProperty.Register(nameof(UseAutoHideTitleBar), typeof(bool), typeof(CustomToolWindow), new PropertyMetadata(false));
public CustomToolWindow(DockSite dockSite, string serializationId, string title, ImageSource imageSource, object content)
: base(dockSite, serializationId, title, imageSource, content)
{
}
protected override void OnVisualParentChanged(DependencyObject oldParent)
{
base.OnVisualParentChanged(oldParent);
if (this.UseAutoHideTitleBar && this.Parent is ToolWindowContainer toolWindowContainer)
{
toolWindowContainer.MouseEnter -= OnMouseEnter;
toolWindowContainer.MouseEnter += OnMouseEnter;
toolWindowContainer.MouseLeave -= OnMouseLeave;
toolWindowContainer.MouseLeave += OnMouseLeave;
void OnMouseEnter(object sender, MouseEventArgs e)
{
if (sender is ToolWindowContainer toolWindowContainer)
{
var selectedToolWindow = toolWindowContainer.SelectedToolWindow;
selectedToolWindow.HasTitleBar = true;
}
}
void OnMouseLeave(object sender, MouseEventArgs e)
{
if (sender is ToolWindowContainer toolWindowContainer)
{
var window = toolWindowContainer.SelectedToolWindow;
if (window != default)
{
window.HasTitleBar = false;
}
}
}
}
}
}
It works similarly to what we expected, but there's a little bit of a problematic.
It blinks when I float the ToolWindows and over the mouse.
Please refer to the video on the link.
Please let me know if there is a good way for you.
Thank you.
[Modified 2 years ago]