Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ConstrainedBox and Attached Shadow docs #567

Merged

Conversation

michael-hawker
Copy link
Collaborator

@michael-hawker michael-hawker commented Sep 17, 2021

Docs for Toolkit PR #4104 and #4179

What changes to the docs does this PR provide?

Adds new docs for the ConstrainedBox, AttachedCardShadow, and AttachedDropShadow controls.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Correctly picked the right branch to base the change off (dev for new features, master for typos/improvements)
  • For new pages, used the provided template
  • For new features, added an entry in the Table of Contents
  • Ran against a spell and grammar checker
  • Contains NO breaking changes

Other information

@michael-hawker michael-hawker added this to the 7.1 milestone Sep 17, 2021
@opbld30
Copy link

opbld30 commented Sep 17, 2021

Docs Build status updates of commit b9bb8e4:

✅ Validation status: passed

File Status Preview URL Details
docs/.template.md ✅Succeeded
docs/controls/ConstrainedBox.md ✅Succeeded View
docs/toc.md ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@opbld30
Copy link

opbld30 commented Sep 17, 2021

Docs Build status updates of commit 5c6b70e:

✅ Validation status: passed

File Status Preview URL Details
docs/.template.md ✅Succeeded
docs/controls/ConstrainedBox.md ✅Succeeded View
docs/toc.md ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@opbld30
Copy link

opbld30 commented Sep 17, 2021

Docs Build status updates of commit 27d0677:

⚠️ Validation status: warnings

File Status Preview URL Details
docs/helpers/AttachedShadows.md ⚠️Warning View Details
docs/.template.md ✅Succeeded
docs/controls/ConstrainedBox.md ✅Succeeded View
docs/controls/DropShadowPanel.md ✅Succeeded View
docs/toc.md ✅Succeeded View

docs/helpers/AttachedShadows.md

  • Line 64, Column 1: [Warning-file-not-found] Invalid file link: '../resources/images/filename.png'.
  • Line 69, Column 1: [Warning-file-not-found] Invalid file link: 'sample-page-link'.
  • Line 73, Column 3: [Warning-file-not-found] Invalid file link: 'source-code-link'.
  • Line 79, Column 3: [Warning-file-not-found] Invalid file link: 'link'.
  • Line 80, Column 3: [Warning-file-not-found] Invalid file link: 'link'.

For more details, please refer to the build report.

If you see build warnings/errors with permission issues, it might be due to single sign-on (SSO) enabled on Microsoft's GitHub organizations. Please follow instructions here to re-authorize your GitHub account to Docs Build.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

Note: Your PR may contain errors or warnings unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:

@opbld32
Copy link

opbld32 commented Sep 17, 2021

Docs Build status updates of commit 4e01c16:

⚠️ Validation status: warnings

File Status Preview URL Details
docs/helpers/AttachedShadows.md ⚠️Warning View Details
docs/.template.md ✅Succeeded
docs/controls/ConstrainedBox.md ✅Succeeded View
docs/controls/DropShadowPanel.md ✅Succeeded View
docs/toc.md ✅Succeeded View

docs/helpers/AttachedShadows.md

  • Line 66, Column 1: [Warning-file-not-found] Invalid file link: '../resources/images/filename.png'.
  • Line 70, Column 1: [Warning-file-not-found] Invalid file link: 'sample-page-link'.
  • Line 74, Column 3: [Warning-file-not-found] Invalid file link: 'source-code-link'.
  • Line 78, Column 3: [Warning-file-not-found] Invalid file link: 'link'.
  • Line 79, Column 3: [Warning-file-not-found] Invalid file link: 'link'.

For more details, please refer to the build report.

If you see build warnings/errors with permission issues, it might be due to single sign-on (SSO) enabled on Microsoft's GitHub organizations. Please follow instructions here to re-authorize your GitHub account to Docs Build.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

Note: Your PR may contain errors or warnings unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:

@opbld32
Copy link

opbld32 commented Sep 18, 2021

Docs Build status updates of commit 22b0a75:

⚠️ Validation status: warnings

File Status Preview URL Details
docs/helpers/AttachedShadows.md ⚠️Warning View Details
docs/.template.md ✅Succeeded
docs/controls/ConstrainedBox.md ✅Succeeded View
docs/controls/DropShadowPanel.md ✅Succeeded View
docs/toc.md ✅Succeeded View

docs/helpers/AttachedShadows.md

  • Line 66, Column 1: [Warning-file-not-found] Invalid file link: '../resources/images/filename.png'.
  • Line 70, Column 1: [Warning-file-not-found] Invalid file link: 'sample-page-link'.
  • Line 74, Column 3: [Warning-file-not-found] Invalid file link: 'source-code-link'.
  • Line 78, Column 3: [Warning-file-not-found] Invalid file link: 'link'.
  • Line 79, Column 3: [Warning-file-not-found] Invalid file link: 'link'.

For more details, please refer to the build report.

If you see build warnings/errors with permission issues, it might be due to single sign-on (SSO) enabled on Microsoft's GitHub organizations. Please follow instructions here to re-authorize your GitHub account to Docs Build.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

Note: Your PR may contain errors or warnings unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:

@opbld32
Copy link

opbld32 commented Sep 20, 2021

Docs Build status updates of commit d5ebc03:

✅ Validation status: passed

File Status Preview URL Details
docs/helpers/AttachedShadows.md 💡Suggestion View Details
docs/.template.md ✅Succeeded
docs/controls/ConstrainedBox.md ✅Succeeded View
docs/controls/DropShadowPanel.md ✅Succeeded View
docs/resources/images/Helpers/Shadows/CardShadow.png ✅Succeeded View
docs/resources/images/Helpers/Shadows/ShadowHover.gif ✅Succeeded View
docs/resources/images/Helpers/Shadows/TextShadow.png ✅Succeeded View
docs/toc.md ✅Succeeded View

docs/helpers/AttachedShadows.md

  • Line 173, Column 3: [Suggestion-docs-link-absolute] Absolute link 'https://docs.microsoft.com/windows/uwp/composition/composition-shadows' will be broken in isolated environments. Replace with a relative link.
  • Line 174, Column 3: [Suggestion-docs-link-absolute] Absolute link 'https://docs.microsoft.com/uwp/api/Windows.UI.Composition.DropShadow' will be broken in isolated environments. Replace with a relative link.

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@michael-hawker michael-hawker marked this pull request as ready for review September 20, 2021 20:06
@michael-hawker michael-hawker changed the title Add ConstrainedBox doc Add ConstrainedBox and Attached Shadow docs Sep 20, 2021
@opbld30
Copy link

opbld30 commented Sep 20, 2021

Docs Build status updates of commit cad8e6b:

✅ Validation status: passed

File Status Preview URL Details
docs/helpers/AttachedShadows.md 💡Suggestion View Details
docs/.template.md ✅Succeeded
docs/controls/ConstrainedBox.md ✅Succeeded View
docs/controls/DropShadowPanel.md ✅Succeeded View
docs/resources/images/Helpers/Shadows/CardShadow.png ✅Succeeded View
docs/resources/images/Helpers/Shadows/ShadowHover.gif ✅Succeeded View
docs/resources/images/Helpers/Shadows/TextShadow.png ✅Succeeded View
docs/toc.md ✅Succeeded View

docs/helpers/AttachedShadows.md

  • Line 173, Column 3: [Suggestion-docs-link-absolute] Absolute link 'https://docs.microsoft.com/windows/uwp/composition/composition-shadows' will be broken in isolated environments. Replace with a relative link.
  • Line 174, Column 3: [Suggestion-docs-link-absolute] Absolute link 'https://docs.microsoft.com/uwp/api/Windows.UI.Composition.DropShadow' will be broken in isolated environments. Replace with a relative link.

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@opbld33
Copy link

opbld33 commented Sep 20, 2021

Docs Build status updates of commit 1d607d8:

✅ Validation status: passed

File Status Preview URL Details
docs/.template.md ✅Succeeded
docs/controls/ConstrainedBox.md ✅Succeeded View
docs/controls/DropShadowPanel.md ✅Succeeded View
docs/helpers/AttachedShadows.md ✅Succeeded View
docs/resources/images/Helpers/Shadows/CardShadow.png ✅Succeeded View
docs/resources/images/Helpers/Shadows/ShadowHover.gif ✅Succeeded View
docs/resources/images/Helpers/Shadows/TextShadow.png ✅Succeeded View
docs/toc.md ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

Copy link
Contributor

@XAML-Knight XAML-Knight left a comment

Choose a reason for hiding this comment

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

Spelling, grammar


# ConstrainedBox

The [ConstrainedBox](/dotnet/api/microsoft.toolkit.uwp.ui.controls.constrianedbox) is a simple `FrameworkElement` content decorator control which allows the developer to constrain its child content one or more various properties including aspect ratio, scale, and aligning to a multiple.
Copy link
Contributor

Choose a reason for hiding this comment

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

constrainedbox

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, " ... control which allows the developer to constrain its child content to one or more various properties ..."

> [!NOTE]
> For technical reasons this control inherits from `ContentPresenter`; however, it should be treated as a `FrameworkElement` and its border and template properties should not be used for compatibility in the future when it can inherit from FrameworkElement directly.

> **Platform APIs:** [`ConstrainedBox`](/dotnet/api/microsoft.toolkit.uwp.ui.controls.constrianedbox), [`AspectRatio`](/dotnet/api/microsoft.toolkit.uwp.ui.controls.aspectratio)
Copy link
Contributor

Choose a reason for hiding this comment

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

constrainedbox


2. `MultipleX`/`MultipleY`: The multiple values allow a developer to snap the layout size of the child to a specific multiple value. For instance, by providing a value of 4, you would ensure the child element is closest to the size of 16, 20, 24, etc... The floor is taken so the child element is always smaller within the bounds of its parent. By default this value is not set so that no extra layout rounding occurs.

3. `AspectRatio`: The aspect ratio can be provided by a double value or a colon separated aspect, e.g. "16:9" and will restrict the layout of the child element to that available space. Therefore if you stretch your child element you can ensure it maintains the desired aspect ratio. By default, no aspect ratio constraint is applied.
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to either surround the whole e.g. with parenthesis, or else put a comma after the e.g. example (... e.g. "16:9", in this case)


3. `AspectRatio`: The aspect ratio can be provided by a double value or a colon separated aspect, e.g. "16:9" and will restrict the layout of the child element to that available space. Therefore if you stretch your child element you can ensure it maintains the desired aspect ratio. By default, no aspect ratio constraint is applied.

If a `ConstrainedBox` is placed in a container which doesn't restrict its size in both the horizontal and vertical directions, it will try and determine its constraints based on the desired size of its child element. If only one direction has infinite size, the control will attempt to use the fixed dimension to measure all constraints against.
Copy link
Contributor

Choose a reason for hiding this comment

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

... try to determine its constraints ..., unless your audience is predominately British, in which case and is acceptable


## Introduction

There are two types of attached shadows available today, the `AttachedCardShadow` and the `AttachedDropShadow`. It is recommended to use the `AttachedCardShadow` where possible, if you don't mind the dependency on Win2D. The `AttachedCardShadow` provides an easier to use experience that is more performant and easier to apply across an entire set of elements, assuming those elements are rounded-rectangular in shape. Whereas, the `AttachedDropShadow` provides masking support and can be leveraged in any UWP app without adding an extra dependency.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest dropping the 'Whereas' in " ... Whereas, the AttachedDropShadow provides masking support ..."

> [!div class="nextstepaction"]
> [Try it in the sample app](uwpct://controls?sample=attachedcardshadow%20%28win2d%29)

The great benefit to the `AttachedCardShadow` is that no extra surface or element is required to add the shadow. This reduces the complexity required on development and allows shadows to easily be added at any point in the development process. It also supports elements which are transparent without seeing the shadow behind them!
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace the on with in, as in "... This reduces the complexity required in development and ...,"

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, for the last sentence in this paragraph, something more like "It also supports transparent elements, which won't see a shadow behind them!"


### Remarks

While `DropShadowPanel` encapsulated the complexities of adding a shadow, it added a lot of depth and complexity to the visual tree. `AttachedDropShadow` instead requires that you provide the surface where the shadows should be cast, such as a common backdrop element. This means that each shadow can use the same shared surface rather than creating its own backdrop element for each shadow (like `DropShadowPanel` did). This slight trade-off for ease-of-use is gained in performance. However, it does mean it may not be as flexible for certain use cases with manipulation of an element. In those cases we recommend to try and use `AttachedCardShadow` instead or wrapping an element and its backdrop in a custom control.
Copy link
Contributor

Choose a reason for hiding this comment

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

... This slight trade-off for ease-of-use is a gain in performance. ...

> **Platform APIs:** [`BlurRadiusDropShadowAnimation`](/dotnet.api/microsoft.toolkit.uwp.ui.animations.blurradiusdropshadowanimation), [`ColorDropShadowAnimation`](/dotnet.api/microsoft.toolkit.uwp.ui.animations.colordropshadowanimation), [`OffsetDropShadowAnimation`](/dotnet.api/microsoft.toolkit.uwp.ui.animations.offsetdropshadowanimation), [`OpacityDropShadowAnimation`](/dotnet.api/microsoft.toolkit.uwp.ui.animations.opacitydropshadowanimation)

> [!NOTE]
> `AttachedCardShadow` has better support for animations which involve translation of the element with the shadow. If animating an `AttachedDropShadow` it is best to only animate the shadow itself vs. moving the element it is attached to. This can cause the shadow and element to be desynchronized.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest "... support for animations which involve translation of the element along with the shadow ..."

  • or -

"... support for animations which involve translation of both the element and the shadow combined ..."

@opbld30
Copy link

opbld30 commented Sep 20, 2021

Docs Build status updates of commit 4eea85f:

✅ Validation status: passed

File Status Preview URL Details
docs/.template.md ✅Succeeded
docs/controls/ConstrainedBox.md ✅Succeeded View
docs/controls/DropShadowPanel.md ✅Succeeded View
docs/helpers/AttachedShadows.md ✅Succeeded View
docs/resources/images/Helpers/Shadows/CardShadow.png ✅Succeeded View
docs/resources/images/Helpers/Shadows/ShadowHover.gif ✅Succeeded View
docs/resources/images/Helpers/Shadows/TextShadow.png ✅Succeeded View
docs/toc.md ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@michael-hawker michael-hawker merged commit b444b6e into MicrosoftDocs:master Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants