[英]How to get the angle of an UIElement in Windows Phone Silverlight?
我被這段代碼所困擾,在代碼中找不到如何獲取此Path元素的角度,請幫幫我! 我的目的是檢查當其父元素“ CamGrid”旋轉時“ vectorCapture”的角度。 非常感謝! 這是我的XAML代碼:
<phone:PhoneApplicationPage.Resources>
<Storyboard x:Name="RotateCamera" RepeatBehavior="Forever">
<DoubleAnimation
Duration="0:0:10" To="360"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)"
Storyboard.TargetName="CamGrid"
d:IsOptimized="True" />
</Storyboard>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid Name="CamGrid"
RenderTransformOrigin=".5, .5">
<Grid.RenderTransform>
<CompositeTransform x:Name="CamGridCompositeTransform" />
</Grid.RenderTransform>
<Path Data="M4,16h1.6V5.6H16V4H4V16z M5.6,27.2H4v12h12v-1.6H5.6V27.2z M37.6,16h1.6V4h-12v1.6h10.4V16z M9.6,20.8H0v1.6
h9.6V20.8z M20.8,43.2h1.6v-9.6h-1.6V43.2z M37.6,37.6H27.2v1.6h12v-12h-1.6V37.6z M20.8,9.6h1.6V0h-1.6V9.6z M33.6,20.8v1.6h9.6
v-1.6H33.6z M33.6,20.8"
Name="vectorCapture"
Fill="{Binding Path=LocalizedResources.ForeColor2,
Source={StaticResource LocalizedStrings}}"
Stroke="{Binding Path=LocalizedResources.ForeColor2,
Source={StaticResource LocalizedStrings}}"
StrokeThickness="2"
Height="64"
Width="64"
Margin="0,0,0,0"
Stretch="Uniform"
VerticalAlignment="Bottom"/>
</Grid>
</Grid>
我解決了我的問題,這是我的解決方案:
CompositeTransform CamCT = new CompositeTransform();
CamCT = (CompositeTransform)CamGrid.RenderTransform;
//then get angle by CamCT.Rotation
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.