递归应用转换的 WPF 容器

发布于 2024-10-03 22:40:07 字数 271 浏览 0 评论 0原文

我有一个由许多控件(例如按钮和其他自定义控件)组成的用户控件。

UserControl 还负责与控件交互的各种动画。

现在,我想倒置或侧向使用我的控件。有没有一种方法可以将所有内容放入容器中,然后简单地旋转容器,以便控件所做的所有内容都像以前一样工作,但旋转了(即递归应用旋转变换)?

目前它位于网格中。

编辑:另外,是否也可以将所有控件对齐在一起?目前它们都对齐到中底部。您将所有控件的对齐方式设置为多少,以便您可以更改容器的对齐方式,并且它们都将类似地对齐。

I have a UserControl that is composed of many controls such as Buttons and other custom controls.

The UserControl takes care of various animations that interact with the controls as well.

Now, I'd like to use my control upside down, or sideways. Is there a way to put everything into a container, and simply rotate the container, so that everything that the control did works as before, but rotated (i.e. the rotate transformation is applied recursively)?

Currently it is in a Grid.

EDIT: Also, is it possible to have all the controls align together as well? Currently they all align to middle bottom. What would you set the alignment of all controls to so that you could change the alignment of the container and they would all align similarly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

童话里做英雄 2024-10-10 22:40:07

设置容器的 RenderTransform 或 LayoutTransform 将为您完成此操作。哪一个取决于您的需求——可以在这里找到关于差异的简短而甜蜜的解释:

http://www.scottlogic.co.uk/blog/colin/2008/12/layouttransform-vs-rendertransform-whats-the-difference/

我不确定这个的 xaml,但在 C# 中它很简单:

grid.RenderTransform = new RotateTransform(90);

Setting the RenderTransform or LayoutTransform of the container will do this for you. Which one depends on your needs -- a short and sweet explanation of the difference can be found here:

http://www.scottlogic.co.uk/blog/colin/2008/12/layouttransform-vs-rendertransform-whats-the-difference/

I'm not sure the xaml for this, but in C# it's as simple as:

grid.RenderTransform = new RotateTransform(90);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文