Skip to content

Conversation

@vinnarayana-msft
Copy link

@vinnarayana-msft vinnarayana-msft commented Dec 29, 2025

This PR introduces an API specification for addressing custom TitleBar draggability issues. The proposal adds a new attached property, IsDragRegion, allowing developers to explicitly mark UI elements within TitleBar Content that should not participate in window dragging. By excluding interactive controls or specific regions, all remaining title bar areas behave predictably as draggable surfaces.

Fixes

PR Type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Description

Custom title bar layouts often mix interactive elements—like buttons and search boxes—with non‑interactive visual elements. When these elements are arranged using containers such as Grid, StackPanel, or nested layouts, the system cannot reliably determine which parts of the TitleBar.Content should act as the draggable window surface. This can leave some areas unintentionally non‑draggable, resulting in inconsistent window movement.

To make dragging behavior predictable, developers need a simple way to exclude only the interactive elements from contributing to the drag surface, allowing the rest of the title bar to function as expected for window dragging. This proposal introduces an attached property to explicitly mark such elements, improving clarity and control in custom title bar designs.

This work is also part of the improvements tracked in #10421.

A lightweight and explicit API is therefore needed to let developers clearly mark non draggable regions within any TitleBar layout while keeping default behaviour unchanged.

Motivation and Context

Introduce a new attached property:

Developers can use the TitleBar.ExcludeFromDrag attached property to indicate which UI elements in a custom title bar should not act as drag surfaces. Interactive controls are typically excluded from dragging, while all other non‑interactive areas of the title bar automatically function as draggable regions.

How Has This Been Tested?

  • I have performed a self-review of my own code
  • I have added tests to cover my changes

Screenshots (if appropriate):

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Dec 29, 2025
@vinnarayana-msft
Copy link
Author

@microsoft-github-policy-service agree

@ghost1372
Copy link
Contributor

@vinnarayana-msft is there any plan to fix titlebar issues?
here you can find a list of titlebar issues:
microsoft/WindowsAppSDK#5250

@vinnarayana-msft vinnarayana-msft changed the title [API Spec] TitleBar's Content IsDraggable Property [API Spec] TitleBar's Content ExcludeFromDrag Property Dec 29, 2025
Copy link

@Zakariathr22 Zakariathr22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest also using IsDragEnabled instead of ExcludeFromDrag because it avoids negative wording and follows common boolean naming rules.

@vinnarayana-msft
Copy link
Author

vinnarayana-msft commented Dec 31, 2025

I suggest also using IsDragEnabled instead of ExcludeFromDrag because it avoids negative wording and follows common boolean naming rules.

Thank you @Zakariathr22 for the suggestion. The intent behind using ExcludeFromDrag is that in custom TitleBar layouts, the entire content region effectively becomes draggable, and developers typically only need to mark interactive controls as not draggable. So the property acts as an opt‑out, not an opt‑in, which makes a negative‑form name more accurate for the underlying behavior.
That said, I’m open to considering alternative names that still convey this opt‑out pattern if there’s a clearer option.

@riverar
Copy link
Contributor

riverar commented Jan 5, 2026

Is there prior art for negative-form Boolean properties? I think it's more common to use positive Boolean properties. +1 to the suggested change here (from ExcludeFromDrag to IsDraggable or IsDragEnabled).

@riverar
Copy link
Contributor

riverar commented Jan 5, 2026

Microsoft Office allows dragging and Microsoft Teams does not. Which one is right?
image

image


### Keyboard Behaviour

This API does not introduce new keyboard interactions by itself; it influences pointer-driven window dragging. However, custom title bar content must still follow common keyboard accessibility expectations:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about touch?


Custom title bar layouts often combine interactive controls with non-interactive visual elements using containers like `Grid`, `StackPanel`, or nested structures. These layouts can unintentionally create gaps or regions whose drag behavior the framework cannot reliably infer. As a result, some title bar areas may unexpectedly become non-draggable, leading to inconsistent window movement.

To ensure predictable dragging behavior, developers need a way to explicitly mark UI elements that should **not** participate in window dragging—typically interactive controls. All remaining areas then function automatically as draggable regions. This proposal introduces the `TitleBar.ExcludeFromDrag` attached property to provide explicit, predictable control.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think ExcludeFromDrag should be renamed to IsDraggable or similar.

See also: https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-type-members#names-of-properties

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on renaming it to be positive. Although, both IsDraggable and IsDragEnabled make it sound, to me, like the control itself is draggable. What about something like IsDragRegion? Sounds weird, but something in this vein.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with above comment.

@Jay-o-Way
Copy link
Contributor

Jay-o-Way commented Jan 8, 2026

So the property acts as an opt‑out, not an opt‑in

Irrelevant. It's a property, and if the default is true then so be it. A property should always have a neutral or positive phrasing.

Also, in my opinion, something like this should have been discussed and agreed upon, before opening a PR. Note that you are a Microsoft employee and therefore a professional level is inherently expected.

@vinnarayana-msft vinnarayana-msft changed the title [API Spec] TitleBar's Content ExcludeFromDrag Property [API Spec] TitleBar's Content Custom Drag Regions Jan 27, 2026
@pranav-gupta-msft
Copy link
Member

The PR Description, can also contain, "BugFix" as this is one of the pending bugs which we are fixing.


# Background

Custom title bar layouts often combine **interactive controls** and **non‑interactive visual elements** using containers such as `Grid`, `StackPanel`, or deeper nested structures. While this flexibility enables rich and branded title bar designs, it also introduces ambiguity when determining **which parts of the title bar should behave as draggable regions** for moving the window.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should give examples of Interactive and Non Interactive visual elements.

![Non draggable gaps in TitleBar Content](./images/titlebar-drag-issue-fixed.png)

#### Notes on behavior
- The framework still uses `ReadLocalValue(IsDragRegionProperty)` to determine whether the developer **explicitly set** a value. If **omitted**, the framework applies the new default drag‑region rules.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If we have a link to the new default drag-region rules, it will be great to add (Otherwise we can ignore)

@Jay-o-Way
Copy link
Contributor

@pranav-gupta-msft how does a SPEC (documents for a new feature) fix an existing BUG? Those are two completely different things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-triage Issue needs to be triaged by the area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants