UWP中如何获取ClientRectangle和DisplayRectangle

How to get ClientRectangle and DisplayRectangle in UWP

我已将 Windows.UI.Xaml.Controls.Scrollview 放入 UWP 中的 Windows.UI.Xaml.Controls.RelativePanel。 现在我正在尝试使用 C# 获取 DisplayRectangle 和 ClientRectangle。

我知道这在使用 C# 的 .Net Framework 中是可能的。

Rectangle client = ClientRectangle;
Rectangle displayRectangle = _displayRect;

我想在 UWP 中做同样的事情。这在 UWP 中可行吗?如果没有,是否有办法获取这两个信息?

How to get ClientRectangle and DisplayRectangle in UWP

UWP 平台中没有属性。根据您的要求,您可以将边框添加到 RelativePanelindicate 显示区域。

<Border BorderBrush="Red" BorderThickness="1">
    <ScrollViewer x:Name= "Test" >

    </ScrollViewer>
</Border>

对于ClientRectangle,您可以调用Content 属性获取客户​​区。

var content =  Test.Content;