WPF控件窗口的位置? [英] Location of WPF control in window?
问题描述
有没有办法让一个WPF的当前呈现的位置控制其窗口的在的所有电流的RenderTransform
取值已应用于?我可能只是盲目的,但我没有看到一个明显的方法。
Is there a way to get the current rendered location of a WPF control its window after all of the current RenderTransform
s have been applied? I may just be blind, but I'm not seeing an obvious method.
推荐答案
我想我应该一直问前戳......但不是删除也许这将帮助别人之后。
I guess I should have kept poking before asking ... but instead of deleting maybe this will help someone later.
的技巧是从控制的轴转换点(0,0)到窗口的轴,所以......
The trick is to transform the point (0,0) from the control's axes to the axes of the window, so...
点renderedLocation = theControl.TranslatePoint(新点(0,0),theWindow);
如果你需要它的工作原理类似于在控制内点,只使用局部点,而不是(0,0)。
If you need an interior point on the control it works similar, just use that local point instead of (0,0).
不要试图立足其关闭保证金
或填充
,它不能正常出来了。
Don't try basing it off of Margin
or Padding
, it doesn't come out correctly.
这篇关于WPF控件窗口的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!