Windows phone 8 方向更改期间的Windows phone列和轴网

Windows phone 8 方向更改期间的Windows phone列和轴网,windows-phone-8,camera,grid,screen-orientation,Windows Phone 8,Camera,Grid,Screen Orientation,嘿,伙计们,我的xml中有这个 <Grid x:Name="LayoutRoot" Background="Black"> <Grid Background="Black"> <Grid.RowDefinitions> <RowDefinition Height="72"/> <RowDefinition Height="*"/> <R

嘿,伙计们,我的xml中有这个

<Grid x:Name="LayoutRoot" Background="Black">
    <Grid Background="Black">
        <Grid.RowDefinitions>
            <RowDefinition Height="72"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="90"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="72"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="90"/>
        </Grid.ColumnDefinitions>

        <StackPanel x:Name="FirstBorder" Background="Red" Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="3"/>

        <Grid Grid.Column="1" Grid.Row="0" Grid.RowSpan="3" x:Name="LivePreviewTapTarget">
            <Canvas>
                <Rectangle x:Name="CameraRectangle" Width="638" Height="480" Fill="{Binding PreviewBrush}">
                    <Rectangle.RenderTransform>
                        <CompositeTransform x:Name="LivePreviewTransform"/>
                    </Rectangle.RenderTransform>
                </Rectangle>
            </Canvas>
        </Grid>

        <Border x:Name="SecondBorder" Background="Yellow" Grid.Column="2" Grid.Row="0" Grid.RowSpan="3"></Border>

这是纵向模式下的页面外观

奇怪的是,我已经在我的HTC 8X上测试了你的代码,效果很好。也许红色已经是您设备上的光摄像机流的一部分了?

作为一种解决方法,我建议在CameraRectangle元素中添加几个负边距像素,这样可以隐藏红色边框。

它仍然不起作用,解决方法确实起到了作用。但我还有一个问题。我更新了我的问题。
if (IsPortrait(Orientation))
        {
            Grid.SetRow(FirstBorder, 0);
            Grid.SetColumn(FirstBorder, 0);
            Grid.SetColumnSpan(FirstBorder, 3);

            Grid.SetRow(LivePreviewTapTarget, 1);
            Grid.SetColumn(LivePreviewTapTarget, 0);
            Grid.SetColumnSpan(LivePreviewTapTarget, 3);

            Grid.SetRow(SecondBorder, 2);
            Grid.SetColumn(SecondBorder, 0);
            Grid.SetColumnSpan(SecondBorder, 3);

            CameraRectangle.Width = 480;
            CameraRectangle.Height = 638;

        }

        else
        {
            Grid.SetColumn(FirstBorder, 0);
            Grid.SetRow(FirstBorder, 0);
            Grid.SetRowSpan(FirstBorder, 3);
            Grid.SetColumn(SecondBorder, 2);
            Grid.SetRow(SecondBorder, 0);
            Grid.SetRowSpan(SecondBorder, 3);
            Grid.SetColumn(LivePreviewTapTarget, 1);
            Grid.SetRow(LivePreviewTapTarget, 0);
            Grid.SetRowSpan(LivePreviewTapTarget, 3);
            CameraRectangle.Width = 638;
            CameraRectangle.Height = 480;
        }

        if (IsPortrait(Orientation))
        {
            _livePreviewTransform.Rotation = _viewModel.ViewfinderRotation;
            _livePreviewTransform.CenterX = 240;
            _livePreviewTransform.CenterY = 400;
            _livePreviewTransform.TranslateX = -100;
            _livePreviewTransform.TranslateY = -160;
        }
        else if (Orientation == PageOrientation.LandscapeRight)
        {
            _livePreviewTransform.Rotation = 180;
            _livePreviewTransform.CenterX = 400;
            _livePreviewTransform.CenterY = 240;
            _livePreviewTransform.TranslateX = -160;
            _livePreviewTransform.TranslateY = 0;
        }
        else
        {
            _livePreviewTransform.Rotation = 0;
            _livePreviewTransform.CenterX = 400;
            _livePreviewTransform.CenterY = 240;
            _livePreviewTransform.TranslateX = 0;
            _livePreviewTransform.TranslateY = 0;
        }

        var scaleX = 1.0;

        if (_viewModel.CameraSensorLocation == CameraSensorLocation.Front)
            scaleX = -1.0;
        _livePreviewTransform.ScaleX = scaleX;