How can I find x, y, width & height of Avalondock LayoutDocument tab using WPF C#?

DINESH KUDALE 6 Reputation points
2021-06-14T19:36:59.443+00:00

I am using WPF C#. Inside my MainWindow, I have used Ribbon control inside the first row and AvalonDock control inside the second row. I want to find x, y co-ordinate of the starting point of LayoutDocument tab from screen (0,0) point. I also want to find the width & height of Avalondock LayoutDocument ? Please refer attached image.105507-xyhw.png

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,784 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,008 questions
{count} votes

1 answer

Sort by: Most helpful
  1. don bradman 621 Reputation points
    2023-05-18T04:26:34.7866667+00:00

    I'm not exactly sure what you're trying to do but you may try the below codes and see if it helps or not :

    // Get the LayoutDocumentPane from the AvalonDock control
    LayoutDocumentPane documentPane = dockManager.Layout.Descendents().OfType<LayoutDocumentPane>().FirstOrDefault();
    
    // Get the first LayoutDocument from the LayoutDocumentPane
    LayoutDocument document = documentPane.Children.FirstOrDefault() as LayoutDocument;
    
    // Get the starting point of the LayoutDocument tab from the screen (0,0) point
    Point startingPoint = document.GetFloatingWindow().PointToScreen(new Point(0, 0));
    
    // Get the width and height of the AvalonDock LayoutDocument
    double width = document.ActualWidth;
    double height = document.ActualHeight;
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.