Kyle
Kyle

Reputation: 22065

In WPF, how do I get the true size of a FrameworkElement?

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?

Upvotes: 0

Views: 437

Answers (1)

Ana Betts
Ana Betts

Reputation: 74702

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.

Upvotes: 1

Related Questions