ToolWindowContainer style lost after dragging and docking again

Docking/MDI for WPF Forum

Posted 5 years ago by Hari Selio
Version: 19.1.0681
Platform: .NET 4.7
Environment: Windows 10 (64-bit)
Avatar

Hello,

I've been evaluating actipro docking control to replace the existing control in our software.  There are few issues we have encountered...

1. I've set style of ToolWindowContainer in the application resources globally.  First time when docking manager shown, the toolwindow shows correct style.  Now make the toolwindow from docking position to floating position by dragging it.  Again set to docking from floating by using mouse drag. After this step, ToolWindowContainer style is lost.  The same actions if i do using context menu(Float or Dock), then no issues.

2.  Is there anyway to restore the default initial position of toolwindow(set by ContainerDockedSize)?  ie., first time it shows in the position set by ContainerDockedSize. Then user resizes it by using the splitter.  After this, i want it go back to the default position if user double clicks on the toolwindow area or splitter.

Comments (6)

Posted 5 years ago by Hari Selio
Avatar

I set metrodark theme for the docksite.  If i remove that, then stlye is retained during drag and dock operation.  How do i retain the style(it contains TitleFontSize and HasTitleBarGripper property) along with the theme.

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Thank you for evaluating our docking windows product.

1) You said it works if you don't switch to Metro Dark, but it's hard to say what's going on without seeing exactly how/where you are applying your Style and what is happening under these scenarios.  Can you either tell us how to alter one of our samples to see the same thing, or send our support address a new simple sample project that shows is happening?  If you send a sample project, reference this thread, remove the bin/obj folders from the ZIP you send, and rename the .zip file extension so it doesn't get spam blocked.  Then we will debug with that.  Hopefully it's an easy thing to work around once we narrow down what's happening.

2) We don't persist the initial position of a tool window.  That being said, you can programmatically dock tool windows (i.e. ToolWindow.Dock(dockSite, Side.Right)) anywhere and can set the ContainerDockedSize right before you do to help ensure the size is correct.  Or alternatively if you wish to just resize them where they are, you can resize the sizes of SplitContainer children.  Pleases see the "Programmatic Sizing" QuickStart in the samples for various examples of this.  The "Docking / Layout, Globalization and Accessibility / Programmatic Layout" topic in the documentation also covers the ResizeSlots method.  We don't have any handling at this time for double-clicking a splitter.

I hope that helps!


Actipro Software Support

Posted 5 years ago by Hari Selio
Avatar

Hello, 

I've sent you the sample in the support mail.  Not much of code changes, just define global style in app.xaml,

<Style TargetType="{x:Type docking:ToolWindowContainer}">
     <Setter Property="TitleFontSize" Value="20" />
     <Setter Property="HasTitleBarGripper" Value="False"></Setter>
</Style>

Then modify one of the samples(i've used WorkspaceContent quickstart) to include theme like below,

<docking:DockSite x:Name="dockSite" themes:ThemeManager.Theme="MetroDark">

Now run the sample, you will see the default MetroDark style applied for the toolwindow.  But once you start dragging the toolwindow, modified global style gets applied.  Again once if we dock the toolwindow, the default metrodark style gets applied.

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Thank you for the sample.  Yes this is because you set the "themes:ThemeManager.Theme" attribute on the docking:DockSite.  That is effectively injecting Styles again at that location and is probably wiping out the ability of your implicit Style to be applied.

I would suggest removing that and in app startup do this instead:

public partial class App : Application {
	protected override void OnStartup(StartupEventArgs e) {
		ActiproSoftware.Windows.Themes.ThemeManager.CurrentTheme = ActiproSoftware.Windows.Themes.ThemeName.MetroDark.ToString();
		base.OnStartup(e);
	}
}

That gets it all working everywhere.


Actipro Software Support

Posted 5 years ago by Hari Selio
Avatar

Setting theme globally solved the issue, thank you.

Regarding the second question about double clicking the splitter or toolwindow to restore the default initial size(we defined default size for each side of docking)...  Just wanted to know, Is there any workaround possible?  I tried the following code,

private void ToolWindow_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (sender is ToolWindow toolWindow)
            {
                var currSide = toolWindow.GetCurrentSide();
                if (currSide != null)
                {
                    toolWindow.ContainerDockedSize = WidthToSizeConverter.GetToolWindowSize((Side)currSide);
                    toolWindow.Dock(dockSite, (Side)currSide);
                }
            }
        }

This above code seems to be working provided only one toolwindow in that group. But if the toolwindow has attached/grouped with other toolwindows, then the double clicked toolwindow is detached from others(as expected).  What i wanted is, entire group toolwindows should be reset to the default size on the current docking side.  I did try using attach API, but the order of toolwindows getting changed.

So is there a easier way to achieve this?  I know i'm asking too much in evaluation period, but what we are looking is to replace the existing control without loosing existing features. 

Thank you.

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Hari,

It might be tough to handle double clicks in the content area of a tool window since other controls generally cover it up and those contorls may handle clicks, preventing the event from getting performed on the tool window.  

We have other more consistent ways you can customize tool windows.  One option would be to customize the context menu to add a menu item that would restore the default initial size.  That way, this menu option could be available if any tool window title bar or tab was clicked.  Our "Custom Context Menu" QuickStart shows that feature.

Another option would be to do something like our "Custom Context Content" QuickStart where you add a button into the title bar.  

But from a UI POV, I would probably suggest the custom menu item for this sort of feature.


Actipro Software Support

The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.