WPF canvas设置旋转角度和偏移位置

 

        /// <summary>
        /// 设置旋转角度和位置
        /// </summary>
        /// <param name="Angle">角度</param>
        /// <param name="CenterX">X轴偏移位置</param>
        /// <param name="CenterY">X轴偏移位置</param>
        /// <returns></returns>
        public TransformGroup SetAngleXY(double Angle, double CenterX, double CenterY)
        {
            TransformGroup tfGroup = new TransformGroup();
            RotateTransform rt = new RotateTransform();
            rt.Angle = Angle;
            rt.CenterX = CenterX;
            rt.CenterY = CenterY;
            tfGroup.Children.Add(rt);
            return tfGroup;
        }
         
         //用法:
         Canvas cvs = new Canvas();
         cvs.RenderTransform = SetAngleXY(180, 0, 0);

 

posted @ 2019-01-14 14:15  紫晶城  阅读(2263)  评论(0编辑  收藏  举报