Adorner Layers removed on Docking view tab change

Docking/MDI for WPF Forum

Posted 10 years ago by Ashok Jacob
Version: 9.1.0507
Avatar
I'm adding an adorner to items in a Dockpanel. When the items are docked my adorner is removed when i switch tabs. When the windows are floating they are fine to switch focus between.

Thought it might be related to the "bug" in the visual studio tab control so I tried the workaround for it in the dockpanel but it doesn't work:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=295933&wa=wsignin1.0

Is there a workaround for this?

Comments (2)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ashok,

Sorry but we'd need to see what you are describing. Please email us a simple sample project showing the issue so we can take a look. Thanks.


Actipro Software Support

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ashok,

Thanks for the sample, I was able to repro this scenario with native WPF controls that is effectively what Docking/MDI does. Add this to your sample XAML:
<Grid Width="200" DockPanel.Dock="Left">
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    
    <ContentControl x:Name="container" />
    <Button x:Name="adornmentTestButton" Grid.Row="1" Content="Click me"  Click="adornmentTestButton_Click" />
</Grid>
Codebehind:
private Button button1 = new Button() { Content= "111" };
private Button button2 = new Button() { Content= "222" };
private void adornmentTestButton_Click(object sender, RoutedEventArgs e) {
    if (container.Content == null) {
        container.Content = button1;
        container.UpdateLayout();
        var adornerLayer = AdornerLayer.GetAdornerLayer(button1);
        if (adornerLayer != null)
            new ProcessingAdorner(button1, adornerLayer);
    }
    else if (container.Content == button1) {
        container.Content = null;
        container.Content = button2;
    }
    else {
        container.Content = null;
        container.Content = button1;
    }
}
Click the button. The first time, your adorner is added. The second time you click the button, another object is swapped into the container (similar to our tab change). Then click the button a third time to restore the original content into the container that should still have an adorner. But the adorner is gone.

Unfortunately I'm not sure what we can do since it's out of our control and is something in Microsoft's code that seems to cause it. You may be better off making your own faux adornment layer but having a Grid as your root docking window content and then adding your processing adorner UI directly to that so it covers the other controls.


Actipro Software Support

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.