本文介绍了在Metro Style应用上计算ViewBox ScaleFactor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过任何方式获取ViewBox在XAML Windows 8 Metro Style应用中缩放其内容的比例因子
Is there any way to get the scale factor by which a ViewBox scales its content in a XAML Windows 8 Metro Style App
推荐答案
WinRTXAMLToolit 对此具有扩展名
public static double GetChildScaleX(this Viewbox viewbox)
{
if (viewbox.Child == null)
throw new InvalidOperationException("Can't tell effective scale of a Viewbox child for a Viewbox with no child.");
var fe = viewbox.Child as FrameworkElement;
if (fe == null)
throw new InvalidOperationException("Can't tell effective scale of a Viewbox child for a Viewbox with a child that is not a FrameworkElement.");
if (fe.ActualWidth == 0)
throw new InvalidOperationException("Can't tell effective scale of a Viewbox child for a Viewbox with a child that is not laid out.");
return viewbox.ActualWidth / fe.ActualWidth;
}
GetChildScaleY
相同,但具有高度.
这篇关于在Metro Style应用上计算ViewBox ScaleFactor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!