Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawer doesn't close adorner border when I switch tabcontrol's tab #1407

Closed
WYihei opened this issue May 29, 2023 · 0 comments
Closed

Drawer doesn't close adorner border when I switch tabcontrol's tab #1407

WYihei opened this issue May 29, 2023 · 0 comments

Comments

@WYihei
Copy link

WYihei commented May 29, 2023

Describe the bug

what I did:

  1. Drawer is inside a tabitem of tabcontrol.
  2. The drawer control has been opened when I switch tabcontrol to another tab.
  3. Switch back to the original tab page containing the drawer control.
  4. Click close button of the drawer.

what I got:
The drawer control is indeed closed, but the mask element is left on the page.

Steps to reproduce the bug

  1. Drawer is inside a tabitem of tabcontrol.
  2. The drawer control has been opened when I switch tabcontrol to another tab.
  3. Switch back to the original tab page containing the drawer control.
  4. Click close button of the drawer.

Expected behavior

AdornerContainer should also be closed.

Screenshots

Snipaste_2023-05-29_22-28-51

NuGet package version

HandyControl 3.4.0

IDE

Visual Studio 2022

Framework type

.Net Framework 4.8

Windows version

Windows 11 (22000)

Additional context

I found a way to fix that by modifying method "OnIsOpenChanged" in drawer.cs.
add:

_container = _layer.GetAdorners(_layer)?.First(c=>c is AdornerContainer) as AdornerContainer;

before

if(_container  == null) 
{
     CreateContainer();
}

at line 305.
BECAUSE:
there is an assignment

_container = null

inside Drawer_Unloaded at line 74 of drawer.cs.

and I think that it's associated with

if(_container  == null) 
{
     CreateContainer();
}

in method "OnIsOpenChanged" at line 305.when I select another tab of tabcontrol,Drawer_Unloaded is invoked,then this assignment makes drawer lose reference to current _container.At the same time,the drawer is not closed!!!
so,if I go back to first tab and click drawer's close button,the "OnIsOpenChanged" will create a new container!Then the previous container was left on the page.
Is it right to do this?

@NaBian NaBian closed this as completed in 8d900ec Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant