/// <summary>
 /// Waits for the next layout update event.
 /// </summary>
 /// <param name="frameworkElement">The framework element.</param>
 /// <returns></returns>
 public static async Task WaitForLayoutUpdateAsync(this FrameworkElement frameworkElement)
 {
     await EventAsync.FromEvent <object>(eh => frameworkElement.LayoutUpdated += eh, eh => frameworkElement.LayoutUpdated -= eh);
 }
 /// <summary>
 /// Waits for the element to unload (disconnect from the main object tree).
 /// </summary>
 public static async Task WaitForUnloadedAsync(this FrameworkElement frameworkElement)
 {
     await EventAsync.FromRoutedEvent(eh => frameworkElement.Unloaded += eh, eh => frameworkElement.Unloaded -= eh);
 }