Skip to content

Add documentation for the new ClipToBounds property #308

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions docs/extensions/UIElementExtensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: UIElement Extensions
author: vgromfeld
description: UIElementExtensions provides a simple way to extend the UIElement
keywords: windows 10, uwp, windows community toolkit, uwp community toolkit, uwp toolkit, UIElement, extensions
---

# UIElement Extensions

The [UIElementExtensions](https://docs.microsoft.com/en-us/dotnet/api/microsoft.toolkit.uwp.ui.extensions.uielementextensions) provide helpers for `UIElement`.

## ClipToBounds

The `ClipToBounds` property allows you to indicate whether to clip the content of this element (or content coming from the child elements of this element) to fit into the size of the containing element.

> [!div class="nextstepaction"]
> [Try it in the sample app](uwpct://Extensions?sample=ClipToBounds)

### Example

```xaml
<Grid
BorderBrush="White"
BorderThickness="1"
Width="148"
Height="148"
extensions:UIElementExtensions.ClipToBounds="True">
<!-- We translate the inner rectangles outside of the bounds of the container. -->
<Rectangle Fill="Blue" Width="100" Height="100">
<Rectangle.RenderTransform>
<TranslateTransform X="-50" Y="-50" />
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="Green" Width="100" Height="100">
<Rectangle.RenderTransform>
<TranslateTransform X="50" Y="50" />
</Rectangle.RenderTransform>
</Rectangle>
</Grid>

```

## Requirements (Windows 10 Device Family)

| [Device family](http://go.microsoft.com/fwlink/p/?LinkID=526370) | Universal, 10.0.16299.0 or higher |
| --- | --- |
| Namespace | Microsoft.Toolkit.Uwp.UI.Extensions |
| NuGet package | [Microsoft.Toolkit.Uwp.UI](https://www.nuget.org/packages/Microsoft.Toolkit.Uwp.UI/) |

## API

- [UIElementExtensions source code](https://github.com/Microsoft/WindowsCommunityToolkit//blob/master/Microsoft.Toolkit.Uwp.UI/Extensions/UIElement)

## Related Topics

- [UIElement.ClipToBounds Property (WPF)](https://docs.microsoft.com/en-us/dotnet/api/system.windows.uielement.cliptobounds?view=netframework-4.8)
1 change: 1 addition & 0 deletions docs/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
## [SurfaceDialTextboxHelper](extensions/SurfaceDialTextboxHelper.md)
## [TextBoxMask](extensions/TextBoxMask.md)
## [TextBoxRegex](extensions/TextBoxRegex.md)
## [UIElementExtensions](extensions/UIElementExtensions.md)
## [ViewExtensions](extensions/ViewExtensions.md)
## [Visual Tree](extensions/VisualTree.md)
## [WebViewExtensions](extensions/WebViewExtensions.md)
Expand Down