[英]How to Access Grid View from hub section Data Template Windows phone 8.1 in C#
[英]How to animate grid rotation by compass data ? c# windows phone 8
我正在为wp8创建增强现实应用程序。 它看起来像下面显示的图像。
黑屏将由cam的视频源填充。 对于左上方的小圆圈,我正在使用两个网格。 第一个网格包含柠檬绿线段,此网格将是固定的。 第二个网格包含较大的圆圈,顶部带有字母N。 它必须旋转以通过从设备指南针获取数据来显示北向。
我按照下面给出的文章来模仿罗盘的产生。 http://msdn.microsoft.com/zh-CN/library/windowsphone/develop/hh202974(v=vs.105).aspx
但是在timer_Tick事件中,我必须用字母N更新褐色网格的旋转。对于如何从指南针数据获取网格的实时旋转,我一无所知。 我如何使用情节提要来提供角度? 还是有没有更简单的方法而不启动和停止情节提要和所有大惊小怪?
网格xaml代码如下。
<Grid Name="StationaryLittleMap" Width="150" Height="150" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="20,20,0,0">
<Path Stroke="White" Fill="LimeGreen" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure StartPoint="38,10">
<PathFigure.Segments>
<PathSegmentCollection>
<ArcSegment Size="75,75" RotationAngle="36" IsLargeArc="False" SweepDirection="Clockwise" Point="112,10" />
<LineSegment Point="75,75" />
<LineSegment Point="38,10" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
</Grid>
<Grid Name="MoveLittleMap" Width="150" Height="150" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="20,20,0,0" >
<Grid.RenderTransform>
<CompositeTransform />
</Grid.RenderTransform>
<Ellipse Fill="Orange" Height="150" Width="150" RenderTransformOrigin="0.5,0.5" Opacity="0.4" />
<TextBlock Text="N" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,0,0,0" />
</Grid>
如果您对动画不感兴趣,则可以直接更新CompositeTransform。
首先,在XAML中为其命名:
<CompositeTransform x:Name="CompassTransform" />
然后,直接从代码中更改角度:
this.CompassTransform.Rotation = 45;
但是,如果您希望指南针平滑旋转,那么除了使用情节提要板之外,您别无选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.