WP7视频画笔方向

时间:2013-01-29 01:46:23

标签: windows-phone-7

我在这里和不同的门户网站上经历了几个Q& A但是无法让这个工作...... 我的页面方向是Portrait ...

    <Rectangle x:Name="videoRectangle" Margin="0,0,0,0">
        <Rectangle.Fill>
            <VideoBrush x:Name="viewfinderBrush" AlignmentX="Left" AlignmentY="Top" Stretch="UniformToFill">
                <VideoBrush.RelativeTransform>
                    <CompositeTransform x:Name="videoBrushTransform" CenterX="0.5" CenterY="0.5" />
                </VideoBrush.RelativeTransform>
            </VideoBrush>
        </Rectangle.Fill>
    </Rectangle>

ARPage_OrientationChanged背后的代码永远不会被调用

    public ARPage()
    {
        InitializeComponent();

        this.OrientationChanged += ARPage_OrientationChanged;
    }

    void ARPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
    {
        abc.Text = e.Orientation.ToString();

        switch (e.Orientation)
        {
            case PageOrientation.Landscape:
            case PageOrientation.LandscapeLeft:
                videoBrushTransform.Rotation = 0;
                break;
            case PageOrientation.LandscapeRight:
                videoBrushTransform.Rotation = -45;
                break;
            case PageOrientation.Portrait:
            case PageOrientation.PortraitUp:
                videoBrushTransform.Rotation = -270;
                break;
            case PageOrientation.PortraitDown:
                videoBrushTransform.Rotation = -90;
                break;
        }
    }

视频画笔始终以横向模式显示视频...

我做错了什么

1 个答案:

答案 0 :(得分:0)

没有必要在构造函数中分配事件,您可以这样做:

public ARPage()
    {
        InitializeComponent();
    }


protected override void OnOrientationChanged(OrientationChangedEventArgs e)
        {
            abc.Text = e.Orientation.ToString();

            switch (e.Orientation)
            {
                case PageOrientation.Landscape:
                case PageOrientation.LandscapeLeft:
                    videoBrushTransform.Rotation = 0;
                    break;
                case PageOrientation.LandscapeRight:
                    videoBrushTransform.Rotation = -45;
                    break;
                case PageOrientation.Portrait:
                case PageOrientation.PortraitUp:
                    videoBrushTransform.Rotation = -270;
                    break;
                case PageOrientation.PortraitDown:
                    videoBrushTransform.Rotation = -90;
                    break;
            }

            base.OnOrientationChanged(e);
        }