Back to Devexpress

SimpleButton.AsyncDisplayMode Property

wpf-devexpress-dot-xpf-dot-core-dot-simplebutton-c36a49e8.md

latest3.1 KB
Original Source

SimpleButton.AsyncDisplayMode Property

Gets or sets how the button indicates the progress of an asynchronous operation.

Namespace : DevExpress.Xpf.Core

Assembly : DevExpress.Xpf.Core.v25.2.dll

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public AsyncDisplayMode AsyncDisplayMode { get; set; }
vb
Public Property AsyncDisplayMode As AsyncDisplayMode

Property Value

TypeDescription
AsyncDisplayMode

Specifies how the button indicates the progress of an asynchronous operation.

|

Available values:

NameDescription
None

Asynchronous operations are executed without a visual indication.

| | Wait |

The button displays the wait indicator during the asynchronous operation.

| | WaitCancel |

The button displays the wait indicator and changes it to the cancel button when a user hovers the mouse pointer over the wait indicator. If a user presses the cancel button, the associated asynchronous command’s IsCancellationRequested property is changed to true.

|

Remarks

The SimpleButton control can indicate whether an asynchronous operation is in progress. To enable this behavior, set the SimpleButton.AsyncDisplayMode property to Wait or WaitCancel:

xaml
<dx:SimpleButton Content="Async Button" 
                 AsyncDisplayMode="WaitCancel" 
                 Command="{Binding AsyncCommand}"/>
csharp
using DevExpress.Mvvm;
using System.Threading.Tasks;
// ...

public class ViewModel : ViewModelBase {
    public IAsyncCommand AsyncCommand { get; }

    public ViewModel() {
        AsyncCommand = new AsyncCommand(AsyncMethod);
    }

    async Task AsyncMethod() {
        while(!AsyncCommand.IsCancellationRequested) {
            await Task.Delay(100);
        }
    }
}
vb
Imports DevExpress.Mvvm
Imports System.Threading.Tasks
' ...

Public Class ViewModel
    Inherits ViewModelBase

    Public ReadOnly Property AsyncCommand As IAsyncCommand

    Public Sub New()
        AsyncCommand = New AsyncCommand(AddressOf AsyncMethod)
    End Sub

    Private Async Function AsyncMethod() As Task
        While Not AsyncCommand.IsCancellationRequested
            Await Task.Delay(100)
        End While
    End Function
End Class

See Also

IsAsyncOperationInProgress

SimpleButton Class

SimpleButton Members

DevExpress.Xpf.Core Namespace