Ejemplo n.º 1
0
            /// <summary>
            /// Navigates to the object that is represented by the specified route.
            /// </summary>
            /// <param name="route">The route of the object to navigate to.</param>
            /// <param name="data">The data to pass with the navigation request.</param>
            /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
            /// <returns>The <see cref="Task{TResult}"/> that represents the asynchronous operation.</returns>
            public async Task <bool> NavigateAsync(string route, object data, CancellationToken cancellationToken = default)
            {
                if (UIThread.CheckAccess())
                {
                    return(collection.Navigate(route, data));
                }

                return(await UIThread.InvokeAsync(() => collection.Navigate(route, data), DispatcherPriority.Normal, cancellationToken));
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Navigates to the object that is represented by the specified route.
            /// </summary>
            /// <param name="route">The route of the object to navigate to.</param>
            /// <param name="data">The data to pass with the navigation request.</param>
            /// <returns><c>true</c> if successfully navigated; otherwise, <c>false</c>.</returns>
            public bool Navigate(string route, object data)
            {
                if (UIThread.CheckAccess())
                {
                    return(collection.Navigate(route, data));
                }

                return(UIThread.Invoke(() => collection.Navigate(route, data), DispatcherPriority.Normal));
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Raises the <see cref="ICommand.CanExecuteChanged"/> event for the current <see cref="DelegateCommand{T}"/>.
        /// </summary>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
        /// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
        public async Task RaiseChangedAsync(CancellationToken cancellationToken = default)
        {
            if (UIThread.CheckAccess())
            {
                OnCanExecuteChanged();

                return;
            }

            await UIThread.InvokeAsync(OnCanExecuteChanged, DispatcherPriority.Normal, cancellationToken);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Raises the <see cref="ICommand.CanExecuteChanged"/> event for the current <see cref="DelegateCommand{T}"/>.
        /// </summary>
        public void RaiseChanged()
        {
            if (UIThread.CheckAccess())
            {
                OnCanExecuteChanged();

                return;
            }

            UIThread.Invoke(OnCanExecuteChanged, DispatcherPriority.Normal);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Raises the <see cref="ICommand.CanExecuteChanged"/> event for each <see cref="IDelegateCommand"/> in the specified sequence.
        /// </summary>
        /// <param name="commands">The sequence on whose <see cref="IDelegateCommand"/> elements to raise the event.</param>
        public static void RaiseChanged(this IEnumerable <ICommand> commands)
        {
            Requires.NotNull(commands, nameof(commands));

            List <IDelegateCommand> list = new List <IDelegateCommand>();

            list.AddRange(commands.OfType <IDelegateCommand>());

            if (list.Count > 0)
            {
                if (UIThread.CheckAccess())
                {
                    RaiseChanged(list);

                    return;
                }

                UIThread.Invoke(() => RaiseChanged(list), DispatcherPriority.Normal);
            }
        }