你需要
它
您可以附加
RectangleGeometry
到你的根
Grid
Rect
内部
SizeChanged
每当其宽度或高度更新时发生。
<Grid x:Name="Root" SizeChanged="OnRootGridSizeChanged">
<Grid.Clip>
<RectangleGeometry Rect="0, 0, WidthOfRoot, HeightOfRoot" />
</Grid.Clip>
Loading
您的根事件
网格
InsetClip
Composition
private void OnRootGridLoading(FrameworkElement sender, object args)
{
var rootVisual = ElementCompositionPreview.GetElementVisual(Root);
var clip = rootVisual.Compositor.CreateInsetClip();
rootVisual.Clip = clip;
}