简体   繁体   English

在WinRT / Windows 8中SizeChanged之后触发事件

[英]Fire event after SizeChanged in WinRT / Windows 8

I've got a Grid that resizes when the app is snapped. 我有一个Grid ,该Grid在应用程序捕捉时会调整大小。 It has to update an animation based on the new ActualWidth of an element. 它必须根据元素的新ActualWidth更新动画。 However, when I tie this function to the SizeChanged event, it seems to fire before the snapped view is redrawn, and calculates the previous ActualWidth . 但是,当我将此函数绑定到SizeChanged事件时,似乎在重新绘制捕捉的视图之前触发并计算先前的ActualWidth

How do I ensure that my function runs AFTER the app is redrawn post-snap? 快照后重新绘制应用程序后,如何确保我的功能运行?

Use the LayoutUpdated event to run any code when the layout updates. 布局更新时,请使用LayoutUpdated事件运行任何代码。 Use a bool set to true on SizeChanged and then set to false again before you do anything to make sure you don't cause a loop! 在执行任何操作以确保不会引起循环之前,将在SizeChanged上使用的布尔值设置为true,然后再次将其设置为false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM