Skip to content

"Interactive content" example - Width calculation for "dragRectL" incorrect #4126

Open
@QuickScoP3s

Description

@QuickScoP3s

In the example for "Interactive content", a method is shown to set the drag regions of the titlebar.

However, the following snippet is incorrect:

Windows.Graphics.RectInt32 dragRectL;
dragRectL.X = (int)((LeftPaddingColumn.ActualWidth) * scaleAdjustment);
dragRectL.Y = 0;
dragRectL.Height = (int)(AppTitleBar.ActualHeight * scaleAdjustment);
dragRectL.Width = (int)((IconColumn.ActualWidth
                        + TitleColumn.ActualWidth
                        + LeftDragColumn.ActualWidth) * scaleAdjustment);
dragRectsList.Add(dragRectL);

dragRectL.Width should be equal to LeftDragColumn.ActualWidth, no calculation needed.

The snippit should look like this:

Windows.Graphics.RectInt32 dragRectL;
dragRectL.X = (int) ((LeftPaddingColumn.ActualWidth) * scaleAdjustment);
dragRectL.Y = 0;
dragRectL.Height = (int) (AppTitleBar.ActualHeight * scaleAdjustment);
dragRectL.Width = (int) (LeftDragColumn.ActualWidth * scaleAdjustment);
dragRectsList.Add(dragRectL);

Additional note
The calculation for dragRectR.Width uses the named columns for everything, except the title, which is also named but not used.

A simple change:

Windows.Graphics.RectInt32 dragRectR;
dragRectR.X = (int) ((LeftPaddingColumn.ActualWidth
                    + TitleColumn.ActualWidth  // Change this line
                    + LeftDragColumn.ActualWidth
                    + SearchColumn.ActualWidth) * scaleAdjustment);
dragRectR.Y = 0;
dragRectR.Height = (int) (AppTitleBar.ActualHeight * scaleAdjustment);
dragRectR.Width = (int) (RightDragColumn.ActualWidth * scaleAdjustment);
dragRectsList.Add(dragRectR);

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions