Skip to content

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

@WYihei

Description

@WYihei

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions