简体   繁体   English

c#WPF视频旋转在图片框内

[英]c# WPF video rotation inside picturebox

I hosted a picturebox inside a WPF window inside a stackpanel. 我在stackpanel内的WPF窗口内托管了一个图片框。 I put code to rotate the stackpanel but it doesn't also rotate its child elements, why? 我把代码旋转到stackpanel,但是它也不会旋转它的子元素,为什么呢? I want it to rotate the video stream inside the picturebox during runtime when clicking the rotate button. 我希望它在运行时单击旋转按钮时旋转图片框内的视频流。 how do i do it? 我该怎么做?

private void rotate_Click(object sender, RoutedEventArgs e)
{
    RotateTransform rotateTransform = new RotateTransform(45);
    panel.RenderTransform = rotateTransform;
}

You can't rotate Windows Forms controls so you will need to replace the WindowsFormHost with a WPF control to be able to rotate it: 您无法旋转Windows窗体控件,因此您需要使用WPF控件替换WindowsFormHost才能旋转它:

A WindowsFormsHost cannot be rotated. WindowsFormsHost无法旋转。 To suppress this error, handle the LayoutError event and set ThrowException to false 要抑制此错误,请处理LayoutError事件并将ThrowException设置为false

Layout Considerations for the WindowsFormsHost Element: https://msdn.microsoft.com/en-us/library/ms744952%28v=vs.110%29.aspx WindowsFormsHost元素的布局注意事项: https //msdn.microsoft.com/en-us/library/ms744952%28v=vs.110%29.aspx

Windows Forms controls cannot be rotated or skewed. Windows窗体控件无法旋转或倾斜。 The WindowsFormsHost element raises the LayoutError event if you apply a skew or rotation transformation. 如果应用倾斜或旋转变换,WindowsFormsHost元素将引发LayoutError事件。 If you do not handle the LayoutError event, an InvalidOperationException is raised. 如果您不处理LayoutError事件,则会引发InvalidOperationException。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM