ToolWindow with Visible=Collapsed visible in Auto-hide mode

Docking/MDI for WPF Forum

Posted 10 years ago by Bjørnar Sundsbø - Norway
Version: 9.1.0507
Avatar
Hi

Depending on the UserLevel of the logged on user in my application, I want to hide a ToolWindow if the user shouldn't have access to that window. The trouble is that it works when the ToolWindow is docked, however, when it's State is auto-hide, the ToolWindow is visible in the tab list.

One approeach I have tried is setting the toolwindow.Visibility = Collapsed, which does not work in auto-hide state. The other approach I tried is using code-behind to add the toolwindow to the toolwindowcontainer only if the logged on user should see the ToolWindow. When the user loggs off, the ToolWindow is removed from the container. This works well if the toolwindow is in Docked state. If the container is in auto-hide, I am not able to add or remove the specific toolwindow, or even get a positive result from Contains on the collection. It seems the toolwindow is removed from it's containers items collection when in auto-hide.

I also tried being notified about state changes for a ToolWindow when the StateProperty changes, and make sure the Visibility property remains Collapsed. However, if I set it to collapsed, it remains Collapsed between state changes. So obviously it is not the ToolWindow instance being displayed in the ItemContainer while the toolwindocontainer is in autohide state.

How can I hide a ToolWindow and make it stay hidden both in Docked and Auto-hide state?

/Bjørnar

[Modified at 01/13/2010 10:46 AM]


Bjørnar Sundsbø

Comments (5)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bjørnar,

Instead of setting the Visibility, you should use the Activate/Open/Close methods. Also, in general you shouldn't access ToolWindowContainers directly as they are created and destroyed, and their children dynamically updated, as ToolWindows are docked/floated/auto-hidden.

Your best bet would probably be to iterate over the DockSite.ToolWindows collection and close the ToolWindows you don't want displayed. If this doesn't work, please put together a small sample project that reproduces the issue and email it over to our support address and we can take a look.


Actipro Software Support

Posted 10 years ago by Bjørnar Sundsbø - Norway
Avatar
This partly solves the issue. It is true it is hidden and displayed as I want it to while the toolwindow is Docked. However, when it is in auto-hide and I use Close, it is placed in its own ToolWindowContainer when I call Open again.

Docking another toolwindow in the previous container, they are all brought back into the same toolwindowcontainer.


Bjørnar Sundsbø

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bjørnar,

What you will probably need to do is check the ToolWindow.State property. When that is AutoHide, then you would call the AutoHide() method instead of the Open. The Open will effectively dock the ToolWindow if it was previously auto-hidden. Otherwise, you'd call the Open method.


Actipro Software Support

Posted 10 years ago by Bjørnar Sundsbø - Norway
Avatar
I was looking at that earlier, but the documentation for ToolWindow.AutoHide() and ToolWindow.Open() was quite limited, so I didn't try it out.

That did not do the trick either (AutoHide(Dock.Righ)). It did activate in the correct state, but was placed in a different ToolWindowContainer than the other ToolWindows.

The following seems to work (once it did not), though it is a messy hack in my opinion. I have to test it a bit more to make sure it is bullet-proof.
EDIT: It does not work the first time, but subsequent operations work (after docking and autohiding them to put them into the same group again).

// There is a bug with Open when window is in AutoHide which places the toolwindow in its own toolwindowContainer - work around it
if (_toolWindowAdminPoiControl.State == DockingWindowState.AutoHide)
{
    _toolWindowAdminPoiControl.AutoHide(Dock.Right);
    _rightToolWindowContainer.AutoHide(Dock.Right);
    _rightToolWindowContainer.Dock();
    _toolWindowAdminPoiControl.Dock();
    _rightToolWindowContainer.AutoHide(Dock.Right);
    _toolWindowAdminPoiControl.AutoHide();
}
else
{
    _toolWindowAdminPoiControl.Open();
}
[Modified at 01/14/2010 02:25 AM]

[Modified at 01/14/2010 02:33 AM]


Bjørnar Sundsbø

Posted 10 years ago by Bjørnar Sundsbø - Norway
Avatar
The following does seem to work. I've done some testing, and have not so far been able to make it fail.

Any suggestions for changes are welcome, however.

// There is a bug with Open when window is in AutoHide which places the toolwindow in its own toolwindowContainer - work around it
if (_toolWindowAdminPoiControl.State == DockingWindowState.AutoHide)
{
    _toolWindowAdminPoiControl.Dock(_toolWindowAddressSearch, Direction.Content);
    _toolWindowAdminPoiControl.AutoHide(Dock.Right);
}
else
{
    _toolWindowAdminPoiControl.Open();
}


Bjørnar Sundsbø

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.