Example #1
0
 /// <summary>
 /// Begins a storyboard and waits for it to complete.
 /// </summary>
 public static async Task BeginAsync(this Storyboard storyboard)
 {
     await EventAsync.FromEvent <object>(
         eh => storyboard.Completed += eh,
         eh => storyboard.Completed -= eh,
         storyboard.Begin);
 }
Example #2
0
        /// <summary>
        /// Waits for the element to load (construct and add to the main object tree).
        /// </summary>
        public static async Task WaitForLoadedAsync(this FrameworkElement frameworkElement)
        {
            if (frameworkElement.IsInVisualTree())
            {
                return;
            }

            await EventAsync.FromRoutedEvent(
                eh => frameworkElement.Loaded += eh,
                eh => frameworkElement.Loaded -= eh);
        }
Example #3
0
 /// <summary>
 /// Waits for the button Click event.
 /// </summary>
 public static async Task <RoutedEventArgs> WaitForClickAsync(this ButtonBase button)
 {
     return(await EventAsync.FromRoutedEvent(
                eh => button.Click += eh,
                eh => button.Click -= eh));
 }
Example #4
0
 /// <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);
 }
Example #5
0
 /// <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);
 }