开发者

Getting an icon to always be unrotated regardless of parent rotations in WPF

Is there an easy way in W开发者_C百科PF to specify the orientation of an icon (or Button, or any WPF object) so that it always effectively remains unrotated regardless of the rotations of the parent transforms?

For example, I'd like to have an icon like this:

+   +   +
+   +
+++++   +
+   +   +
+   +   +

However, if I dock it to the left side, it'd by default look like this:

+++++
  +
  +
  +
+++++

+++ +

and if I docked it to the right, it'd be like this:

+ +++

+++++
  +
  +
  +
+++++

Is there a way to make it always be:

+   +   +
+   +
+++++   +
+   +   +
+   +   +

? I know I could manually track where it's docked and rotate it appropriately, but I was wondering if there's a clever way to effectively give the icon "gravity" to always point down.

Thanks!


No, there isn't one in the WPF framework.

You could build one yourself, however, by creating a behavior that you can attach to any framework element and have it track the rotation transforms of all the elements above it up to the visual tree root or a specific element, then build an opposite transform. Unfortunately, there isn't a really good way to track all the changes in the visual tree, to determine when you need to rebuild the transform.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜