Skip to content

A status center that tracks the progress of operations, from long-running tasks with detailed progress to quick status notifications.

StatusCenterButton ​

Property ​

Name
FlyoutPlacement
SizeUnitFormat
Icon
NoItemsText
ShowProgressRing
AverageOperationProgressValue
IsOperationProgressIndeterminate
InfoBadgeValue
InfoBadgeState

NOTE

ShowProgressRing, AverageOperationProgressValue, IsOperationProgressIndeterminate, InfoBadgeValue and InfoBadgeState are read-only state mirrors for the control template.

Methods ​

Name
Open
AddCard
RemoveItem
RemoveAllCompletedItems
UpdateCardStrings

StatusCenter ​

The flyout panel hosted inside StatusCenterButton.

Property ​

Name
StatusCenterItems
HasAnyItem
EmptyStateVisibility
NoItemsText
SizeUnitFormat

Methods ​

Name
AddCard
RemoveItem
RemoveAllCompletedItems
UpdateCardStrings

NOTE

SizeUnitFormat — BinaryUnits uses KiB/MiB/GiB (1024-based), DecimalUnits uses KB/MB/GB (1000-based).

AddCard ​

Available on both StatusCenterButton and StatusCenter.

csharp
public StatusCenterItem AddCard(
    ReturnResult status,
    string header,
    string subHeader,
    string message,
    StatusCenterItemIconKind iconKind,
    bool canProvideProgress = true,
    long itemsCount = 0,
    long totalSize = 0,
    Func<StatusCenterItem, StatusCenterItemProgressModel, (string Header, string SubHeader, string Message)>? update = null)
NameTypeRemark
statusReturnResultOperation state. InProgress creates a cancellation token.
headerstringMain card text.
subHeaderstringDetailed description shown in the header tooltip; header is used when empty.
messagestringProgress text for determinate in-progress cards.
iconKindStatusCenterItemIconKindIcon for InProgress and Cancelled cards.
canProvideProgressboolfalse shows indeterminate progress and hides details.
itemsCountlongKnown or estimated number of items.
totalSizelongKnown or estimated total bytes.
updatedelegate?Called per progress report; return updated Header, SubHeader, Message.

StatusCenterItem ​

Property ​

NameRemark
HeaderMain card text.
HeaderTooltipTooltip shown for the header text.
SubHeaderDetailed description shown in the header tooltip; Header is used when empty.
MessageProgress text; hidden when IsIndeterminateProgress is true.
ProgressPercentageCurrent progress percentage.
ProgressPercentageTextProgress percentage as display text (e.g. 42%).
SpeedTextFormatted speed text (e.g. 12.3 MiB/s or 450 items/s); updated on progress reports.
SizeUnitFormatSize unit format for this card's size strings (BinaryUnits/DecimalUnits); mirrors the owning control's SizeUnitFormat.
CurrentProcessingItemNameName of the item currently being processed.
IsExpandedCard expansion state.
AnimatedIconStateState of the animated expand icon (NormalOn/NormalOff).
IsSpeedAndProgressAvailableDetermines whether the card can be expanded.
IsIndeterminateProgressShows an indeterminate progress bar; hides Message and CurrentProcessingItemName.
IsPausableDetermines whether the item can be paused; shows the pause action in the options menu.
IsPausedWhether the operation is currently paused; switches ItemKind to Paused while IsInProgress and drives SpeedGraphState and the pause/resume UI.
HasActionstrue when IsCancelable or IsPausable is true; controls the options button visibility.
SpeedGraphStateSpeed graph color state — GraphState.Warning while paused, otherwise GraphState.Normal.
PauseButtonTextText of the pause menu item — Pause or Resume.
PauseButtonIconGlyphGlyph of the pause menu item icon — &#xE769; for Pause, &#xE768; for Resume.
OnPauseAsyncOptional callback awaited when the item is paused; use it to suspend the underlying operation (e.g. pause a download).
OnResumeAsyncOptional callback awaited when the item is resumed; use it to continue the underlying operation.
IsCancelableDetermines whether the item can be cancelled.
ItemKindVisual state of the card.
ItemIconKindBuilt-in icon kind.
IconSourceCustom icon; accepts PathIconSource, FontIconSource, BitmapIconSource, SymbolIconSource, or AnimatedIconSource. For FontIconSource, set FontSize to 16.
IconBackgroundCircleBorderOpacityOpacity of the icon background circle.
OperationReturnResultThe card's ReturnResult state.
TotalItemsCountNumber of items in the operation.
TotalSizeTotal size in bytes.
IsInProgressWhether the operation is still running.
UpdateStringsRewrites Header, SubHeader, Message on each progress report.
CancellationTokenCancelled by CancelCommand; observe it and return ReturnResult.Cancelled.
PauseCommandToggles IsPaused when IsPausable and IsInProgress are true.
CancelCommandCancels CancellationToken; the card shows an indeterminate bar and a Canceling - header prefix until the operation returns.
RemoveCommandRemoves the card from the status center.
ProgressConvenience StatusCenterItemProgressModel that reports through ProgressEventSource.
ProgressEventSourceProgress<StatusCenterItemProgressModel> to report to.
SpeedGraphValuesSpeed history points for the graph; populated automatically.

Methods ​

Name
ExecutePauseCommandAsync
ExecuteCancelCommand
UpdateCardStrings

NOTE

Set IsPausable = true and wire OnPauseAsync/OnResumeAsync to suspend the underlying operation — IsPaused is only a flag; your operation must observe it to actually pause.

StatusCenterItemProgressModel ​

csharp
public StatusCenterItemProgressModel(
    IProgress<StatusCenterItemProgressModel>? progress,
    bool enumerationCompleted = false,
    ReturnResult? status = null,
    long itemsCount = 0,
    int samplerInterval = 100)

Property ​

Name
Status
EnumerationCompleted
FileName
TotalSize
ItemsCount
ProcessedSize
ProcessedItemsCount
ProcessingSizeSpeed
ProcessingItemsCountSpeed
StartTime
CompletedTime
Percentage

Methods ​

Name
AddProcessedItemsCount
SetProcessedSize
Report
ReportStatus

NOTE

ProcessedSize and ProcessedItemsCount are read-only — use SetProcessedSize for an absolute byte count or AddProcessedItemsCount to increment the item count.

NOTE

When enumeration is complete and the processed counts match the totals (or Report(100) is called), an in-progress status converts to success automatically. Use ReportStatus(status, percentage) to change Status and report at the same time.

NOTE

Reporting a completed Status does not remove the card or change its visual state. When the operation ends, remove the in-progress item and add a final card with Success, Failed, or Cancelled.

Enums ​

ReturnResult ​

NameRemark
InProgressOperation is still running. AddCard creates a cancellation token for this state.
SuccessOperation completed successfully.
FailedOperation failed.
CancelledOperation was cancelled.

StatusCenterItemIconKind ​

Name
Copy
Move
Delete
Recycle
Extract
Compress
Successful
Error
Git
InstallFont

StatusCenterItemKind ​

Name
InProgress
Successful
Error
Paused
Canceled

SizeUnitTypes ​

Name
BinaryUnits
DecimalUnits

Example ​

xml
<dev:StatusCenterButton x:Name="StatusCenterButtonSample"
                        FlyoutPlacement="BottomEdgeAlignedRight" />
csharp
private async void Copy_Click(object sender, RoutedEventArgs e)
{
    var fileCount = Random.Shared.Next(3, 9);
    string[] source = FilePaths(@"C:\Users\Public\Documents", fileCount);
    string[] destination = FilePaths(@"C:\Users\Public\Downloads", fileCount);
    var totalSize = fileCount * Random.Shared.NextInt64(24, 97) * 1024 * 1024;
    var banner = AddCard_Copy(StatusCenterButtonSample, ReturnResult.InProgress, source, destination, 0, totalSize);

    var result = await SimulateFileOperationAsync(banner.ProgressEventSource, source, totalSize, banner.CancellationToken, banner);

    StatusCenterButtonSample.RemoveItem(banner);
    AddCard_Copy(StatusCenterButtonSample, result, source, destination, banner.TotalItemsCount, totalSize);
}

private StatusCenterItem AddCard_Copy(StatusCenterButton statusCenterButton,
    ReturnResult returnStatus,
    string[] source,
    string[] destination,
    long itemsCount = 0,
    long totalSize = 0)
{
    var sourcePath = GetParentDir(source.FirstOrDefault());
    var destinationPath = GetParentDir(destination.FirstOrDefault());
    var destinationDirName = destinationPath.Split('\\').Last();

    string ItemsText(long count) => count == 1 ? "1 item" : $"{count} items";

    string Header(long count) => returnStatus switch
    {
        ReturnResult.Cancelled => $"Canceled copying {ItemsText(count)} to \"{destinationDirName}\"",
        ReturnResult.Success => $"Copied {ItemsText(count)} to \"{destinationDirName}\"",
        ReturnResult.Failed => $"Error copying {ItemsText(count)} to \"{destinationDirName}\"",
        _ => $"Copying {ItemsText(count)} to \"{destinationDirName}\""
    };

    string SubHeader(long count) => returnStatus switch
    {
        ReturnResult.Cancelled => $"Canceled copying {ItemsText(count)} from \"{sourcePath}\" to \"{destinationPath}\"",
        ReturnResult.Success => $"Copied {ItemsText(count)} from \"{sourcePath}\" to \"{destinationPath}\"",
        ReturnResult.Failed => $"Failed to copy {ItemsText(count)} from \"{sourcePath}\" to \"{destinationPath}\"",
        _ => $"Copying {ItemsText(count)} from \"{sourcePath}\" to \"{destinationPath}\""
    };

    string Message(StatusCenterItemProgressModel progress)
        => progress.Percentage is null
            ? progress.EnumerationCompleted ? "Processing items..." : "Discovering items..."
            : $"{progress.ProcessedSize.ToSizeString(statusCenterButton.SizeUnitFormat)} of {progress.TotalSize.ToSizeString(statusCenterButton.SizeUnitFormat)} processed";

    var card = statusCenterButton.AddCard(
        returnStatus,
        Header(itemsCount),
        SubHeader(itemsCount),
        "Discovering items...",
        StatusCenterItemIconKind.Copy,
        itemsCount: itemsCount,
        totalSize: totalSize,
        update: (item, progress) => progress.EnumerationCompleted
            ? (Header(item.TotalItemsCount), SubHeader(item.TotalItemsCount), Message(progress))
            : ($"Discovered {ItemsText(item.TotalItemsCount)}", SubHeader(item.TotalItemsCount), Message(progress)));

    if (returnStatus is ReturnResult.InProgress)
        card.IsPausable = true;

    return card;
}

private static async Task<ReturnResult> SimulateFileOperationAsync(
    IProgress<StatusCenterItemProgressModel> progress,
    string[] source,
    long totalSize,
    CancellationToken cancellationToken,
    StatusCenterItem item,
    bool simulateDiscovery = true)
{
    var itemTotal = simulateDiscovery ? Random.Shared.Next(1, 26) : source.Length;
    var progressModel = new StatusCenterItemProgressModel(
        progress,
        enumerationCompleted: !simulateDiscovery,
        status: ReturnResult.InProgress,
        itemsCount: simulateDiscovery ? 0 : itemTotal);

    if (!simulateDiscovery)
    {
        progressModel.TotalSize = totalSize;
        progressModel.Report();
    }

    var pauseDelay = PauseAwareDelay(item);

    try
    {
        if (simulateDiscovery)
        {
            for (var discovered = 1; discovered <= itemTotal; discovered++)
            {
                await pauseDelay(Random.Shared.Next(120, 220), cancellationToken);
                progressModel.ItemsCount = discovered;
                progressModel.Report();
            }
        }

        progressModel.TotalSize = totalSize;
        progressModel.ItemsCount = itemTotal;
        progressModel.EnumerationCompleted = true;
        progressModel.Report();

        await pauseDelay(Random.Shared.Next(50, 500), cancellationToken);
        progressModel.Report(0);

        var failAtPercentage = Random.Shared.Next(0, 100) < 20 ? Random.Shared.Next(40, 85) : double.MaxValue;
        var percentage = 0.0;

        while (percentage < 100)
        {
            var delay = Random.Shared.Next(100, 140);
            if (Random.Shared.Next(0, 15) == 0)
                delay += Random.Shared.Next(150, 300);

            await pauseDelay(delay, cancellationToken);

            percentage = Math.Min(100, percentage + Random.Shared.Next(2, 5));

            var processedItems = Math.Min(itemTotal, (int)Math.Ceiling(itemTotal * percentage / 100));
            var pendingItems = processedItems - progressModel.ProcessedItemsCount;

            if (pendingItems > 0)
                progressModel.AddProcessedItemsCount(pendingItems);

            if (processedItems > 0)
                progressModel.FileName = Path.GetFileName(source[(processedItems - 1) % source.Length]);

            progressModel.Report(percentage);

            if (percentage >= failAtPercentage && percentage < 100)
                return ReturnResult.Failed;
        }

        return ReturnResult.Success;
    }
    catch (OperationCanceledException)
    {
        await Task.Delay(Random.Shared.Next(50, 500), CancellationToken.None);
        return ReturnResult.Cancelled;
    }
}

private static Func<int, CancellationToken, Task> PauseAwareDelay(StatusCenterItem item)
{
    var resumeSignal = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
    item.OnPauseAsync = () =>
    {
        resumeSignal = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
        return Task.CompletedTask;
    };
    item.OnResumeAsync = () =>
    {
        resumeSignal.TrySetResult();
        return Task.CompletedTask;
    };

    return async (millisecondsDelay, cancellationToken) =>
    {
        while (item.IsPaused)
            await resumeSignal.Task.WaitAsync(cancellationToken);

        await Task.Delay(millisecondsDelay, cancellationToken);
    };
}

private static string[] FilePaths(string directory, int count)
    => [.. Enumerable.Range(1, count).Select(i => $@"{directory}\File {i}.txt")];

private static string GetParentDir(string? path)
{
    if (string.IsNullOrEmpty(path))
        return string.Empty;

    var index = path.Contains('/', StringComparison.Ordinal) ? path.LastIndexOf('/') : path.LastIndexOf('\\');
    return path[..(index != -1 ? index : path.Length)];
}

Programmatic open ​

NOTE

Call Open() to toggle the status center flyout programmatically — it opens the flyout, or closes it if it is already open.

xml
<KeyboardAccelerator Key="J" Modifiers="Control" Invoked="ToggleStatusCenter" />
csharp
private void ToggleStatusCenter(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
{
    StatusCenterButtonSample.Open();
    args.Handled = true;
}

StatusCenter

Demo ​

you can run demo and see this feature.

Released under the MIT License.