Beispiel #1
0
        /// <summary>
        /// Shows the given child window on the given container in an asynchronous way.
        /// </summary>
        /// <param name="window">The owning window with a container of the child window.</param>
        /// <param name="dialog">A child window instance.</param>
        /// <param name="container">The container.</param>
        /// <returns></returns>
        /// <exception cref="System.InvalidOperationException">
        /// The provided child window can not add, there is no container defined.
        /// or
        /// The provided child window is already visible in the specified window.
        /// </exception>
        public static Task <TResult> ShowChildWindowAsync <TResult>(
            this Window window,
            ChildWindow dialog,
            Panel container)
        {
            window.Dispatcher.VerifyAccess();

            if (container == null)
            {
                throw new InvalidOperationException("The provided child window can not add, there is no container defined.");
            }

            if (container.Children.Contains(dialog))
            {
                throw new InvalidOperationException("The provided child window is already visible in the specified window.");
            }

            return(ShowChildWindowInternalAsync <TResult>(dialog, container));
        }
Beispiel #2
0
 private static Task AddDialogToContainerAsync(
     ChildWindow dialog,
     Panel container)
 {
     return(Task.Factory.StartNew(() => dialog.Dispatcher.Invoke(new Action(() => container.Children.Add(dialog)))));
 }