C# 如何在UWP中获取ClientRectangle和DisplayRectangle
我已将Windows.UI.Xaml.Controls.Scrollview放入UWP中的Windows.UI.Xaml.Controls.RelativePanel中。 现在,我尝试使用C#获取DisplayRectangle和ClientRectangle 我知道这在.Net框架和C#中是可能的 我想在UWP中也这样做。这在UWP中可能吗?如果没有,有没有办法获得这两个信息 如何在UWP中获取ClientRectangle和DisplayRectangle UWP平台中没有此类属性。根据您的要求,您可以在C# 如何在UWP中获取ClientRectangle和DisplayRectangle,c#,.net,uwp,uwp-xaml,C#,.net,Uwp,Uwp Xaml,我已将Windows.UI.Xaml.Controls.Scrollview放入UWP中的Windows.UI.Xaml.Controls.RelativePanel中。 现在,我尝试使用C#获取DisplayRectangle和ClientRectangle 我知道这在.Net框架和C#中是可能的 我想在UWP中也这样做。这在UWP中可能吗?如果没有,有没有办法获得这两个信息 如何在UWP中获取ClientRectangle和DisplayRectangle UWP平台中没有此类属性。根据您的
RelativePanel
中添加边框,以指示显示区域
<Border BorderBrush="Red" BorderThickness="1">
<ScrollViewer x:Name= "Test" >
</ScrollViewer>
</Border>
ClientRectangle返回一个矩形对象。因此,我们可以得到它的宽度和高度。但是在“var content=Test.content;”中,我们可以访问这些变量吗?不,您不能使用Test.content
获取矩形,如果您想获取内容的大小,请调用ScrollViewerExtentheight
extendwidth
。有关更多信息,请参阅。
<Border BorderBrush="Red" BorderThickness="1">
<ScrollViewer x:Name= "Test" >
</ScrollViewer>
</Border>
var content = Test.Content;