使用WPF圆窗播放电影
是否可以使用 WPF 创建一个圆形窗口并使用正在播放的电影作为背景?
Is it possible with WPF to create a window that has the shape of a circle and uses a playing movie as the background?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以将画布作为父容器(设置为透明),然后添加带有媒体画笔的圆圈作为背景。 应该可以。 :)
you can have a canvas as your parent container (set to transparent) then add a circle with a media brush as it's background. that should do it. :)
要制作非矩形窗口,您需要首先做三件事。
现在,您的窗口是完全透明的。 您可以使用本线程中的其他技巧将一块媒体绘制到窗口的几何图形上。
To make a non-rectangular window, you need to first do three things.
Now, your window is completely transparent. You can use the other tips in this thread to paint a piece of media onto the window's geometry.
您应该只需要在 xaml 中添加类似这样的内容:
实际上使窗口变圆会更困难。 看看这个如果如果你希望窗户是圆形的,它应该有助于解决这个问题。
华泰
You should just need to throw something like this in your xaml:
Actually making the window round would be more difficult. Have a look at this if you want the window to be round, it should help figure that part out.
HTH
不要使用AllowsTransparency,它的性能很差并且存在很多兼容性问题,请访问此链接以获取替代方案:
http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx编辑
:有一个示例如何使用 SetWindowRgn 获取矩形窗口的圆角,如果您传递椭圆区域而不是圆角矩形区域,您将得到一个椭圆窗口,很容易创建一个区域适合您能想象到的任何形状。
Don't use AllowsTransparency, it has very poor performance and a lot of compatibility problems, go to this link for alternatives:
http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx
EDIT: there is an example there how to use SetWindowRgn to get rounded corners for a rectangular windows, if you pass an ellipse region instead of a rounded-rect region you will get an elliptic window, it's easy to create a region for any shape you can imagine.