Created
October 31, 2014 12:27
-
-
Save Grabacr07/5510e17187ae2bf9e9ea to your computer and use it in GitHub Desktop.
Viewbox 内の要素が実際に描画されているサイズを計算するやつ (WPF)。Viewbox 内の要素 (real size を知りたいやつ) から Viewbox 外の要素 (このコードでは Window) にアクセスできれば、その座標系に変換してほげもげっと。たぶん。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Viewbox 内に配置された要素について、実際に描画されているサイズを計算します。 | |
/// </summary> | |
public static Size GetRealSize(FrameworkElement target) | |
{ | |
var min = target.TranslatePoint(new Point(0, 0), Window.GetWindow(target)); | |
var max = target.TranslatePoint(new Point(target.ActualWidth, target.ActualHeight), Window.GetWindow(target)); | |
return (Size)(max - min); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment