在 WPF 中,如何获取 FrameworkElement 的真实大小?
在 WPF 中,如何获取 FrameworkElement 的真实大小,包括投影等效果添加的额外大小?
我有一个带有阴影的按钮。我以编程方式将其输出到 PNG 文件。我使用 ActualWidth 和 ActualHeight 来获取按钮的大小,但这是没有阴影的按钮的大小。
结果是带有投影的按钮被压缩为不带投影的按钮的大小。
有人知道如何计算带有阴影的按钮的大小吗?
In WPF, how do I get the true size of a FrameworkElement, including the extra size that an effect such as a drop shadow adds?
I have a button with a drop shadow on it. I am programmatically outputting it to a PNG file. I use ActualWidth
and ActualHeight
to get the size of the button, however this is the size of the button without the drop shadow.
The result is that the button with the drop shadow is squished into the size of the button without the drop shadow.
Anyone know how to figure out what the size of the button with the drop shadow would be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为这实际上是可能的 - 如果您担心它,请将按钮包裹在边框中并使用填充;这样,阴影就会落在边框上,您不必对任何代码进行特殊处理来处理阴影使用的额外空间。
I don't believe that this is actually possible - if you're worried about it, wrap the button in a border and use padding; this way, the drop shadow falls on the border and you don't have to special-case any code to deal with the extra space used by the shadow.