﻿var td = new TaskDialog
{
    Title = "FluentAvalonia",
    ShowProgressBar = false,
    Content = "Are you sure you want to delete the file?\n" +
    @"../Directory/One/file.txt",
    Buttons =
    {
        TaskDialogButton.YesButton,
        TaskDialogButton.NoButton
    }
};

// Use the closing event to grab a deferral
// You can also cancel closing here if you like
td.Closing += (s, e) =>
{
    // We only want to use the deferral on the 'Yes' Button
    if ((TaskDialogStandardResult)e.Result == TaskDialogStandardResult.Yes)
    {
        var deferral = e.GetDeferral();

        td.ShowProgressBar = true;
        int value = 0;
        DispatcherTimer timer = null;
        void Tick(object s, EventArgs e)
        {
            td.SetProgressBarState(++value, TaskDialogProgressState.Normal);
            if (value == 100)
            {
                timer.Stop();

                // Call this when you're done. It will signal the dialog to resume closing
                deferral.Complete();
            }
        }
        timer = new DispatcherTimer(TimeSpan.FromMilliseconds(75), DispatcherPriority.Normal, Tick);

        timer.Start();
    }
};

// Don't forget to set the XamlRoot!!
td.XamlRoot = VisualRoot;
_ = await td.ShowAsync();
