DownloadPanel

April 9, 2026 · View on GitHub

A panel that visualizes a multi-chunk download operation. Provides a tab strip, a progress bar, a chunk-progress canvas, a chunk details list, and action buttons (pause/resume, cancel).

Basic usage

<DownloadPanel Progress="45"
              IsPaused="False"
              PauseResumeCommand="{Binding PauseResumeCommand}"
              CancelCommand="{Binding CancelCommand}">
    <DownloadPanel.Tabs>
        <x:String>Overview</x:String>
        <x:String>Details</x:String>
    </DownloadPanel.Tabs>
    
    <DownloadPanel.Chunks>
        <controls:ChunkInfo Start="0.0" End="0.5" Progress="1.0" />
        <controls:ChunkInfo Start="0.5" End="1.0" Progress="0.3" />
    </DownloadPanel.Chunks>
</DownloadPanel>

Properties

PropertyTypeDefaultDescription
ProgressdoubleOverall download progress [0..100]
MergeProgressdoubleMerge/post-processing progress [0..100]
IsPausedboolWhether the download is paused
IsMergingboolWhether the download is in the merge/finalize phase
ShowDetailsboolWhether the chunk details section is expanded
IsPauseResumeEnabledtrueboolWhether the pause/resume button is enabled
PauseResumeCommandICommand?Command invoked when pause/resume button is clicked
CancelCommandICommand?Command invoked when cancel button is clicked
ChunkProgressBrushIBrush?Brush used to fill chunk progress rectangles
ChunkBackgroundBrushIBrush?Background brush of the chunk canvas
ChunkItemTemplateIDataTemplate?Data template for chunk list items
TabItemTemplateIDataTemplate?Data template for tab strip items
SelectedTabobject?Currently selected tab item
TabContentobject?Content shown in the tab content area
TabsAvaloniaList<object>Collection of tab items shown in the tab strip
ChunksAvaloniaList<ChunkInfo>Collection of chunk data for canvas visualization and details list

Events

EventDescription
TabSelectionChangedRaised when the selected tab changes

Progress

Update the overall download progress:

downloadPanel.Progress = 45.5; // 45.5%

When in merge phase, use MergeProgress:

downloadPanel.IsMerging = true;
downloadPanel.MergeProgress = 75.0;

Pause/Resume

Control pause state and wire up commands:

downloadPanel.IsPaused = false;
downloadPanel.PauseResumeCommand = new RelayCommand(() =>
{
    downloadPanel.IsPaused = !downloadPanel.IsPaused;
    // Toggle download pause/resume
});

Chunks

Populate the chunks collection to visualize download segments:

downloadPanel.Chunks.Add(new ChunkInfo
{
    Start = 0.0,
    End = 0.25,
    Progress = 1.0,
    ProgressBrush = Brushes.Green
});

downloadPanel.Chunks.Add(new ChunkInfo
{
    Start = 0.25,
    End = 0.5,
    Progress = 0.5,
    ProgressBrush = Brushes.Orange
});

After updating chunk progress, call RedrawChunkCanvas():

chunk.Progress = 0.75;
downloadPanel.RedrawChunkCanvas();

Custom chunk brushes

Customize the appearance of chunk progress:

<DownloadPanel ChunkProgressBrush="#4CAF50"
              ChunkBackgroundBrush="#E0E0E0" />

Or set per-chunk colors:

chunk.ProgressBrush = new SolidColorBrush(Color.Parse("#4CAF50"));

Tabs

Add tabs to the tab strip:

<DownloadPanel>
    <DownloadPanel.Tabs>
        <x:String>Overview</x:String>
        <x:String>Files</x:String>
        <x:String>Settings</x:String>
    </DownloadPanel.Tabs>
</DownloadPanel>

Handle tab selection changes:

downloadPanel.TabSelectionChanged += (sender, e) =>
{
    var selectedTab = downloadPanel.SelectedTab;
    // Update tab content based on selection
};

Details section

Toggle the chunk details section:

<DownloadPanel ShowDetails="True" />
downloadPanel.ShowDetails = !downloadPanel.ShowDetails;

Example

// ViewModel
public class DownloadViewModel
{
    public DownloadPanel DownloadPanel { get; } = new();
    
    public ICommand PauseResumeCommand => new RelayCommand(() =>
    {
        DownloadPanel.IsPaused = !DownloadPanel.IsPaused;
        if (!DownloadPanel.IsPaused)
            ResumeDownload();
        else
            PauseDownload();
    });
    
    public ICommand CancelCommand => new RelayCommand(CancelDownload);
    
    private void UpdateProgress(double progress)
    {
        DownloadPanel.Progress = progress;
    }
    
    private void AddChunk(double start, double end)
    {
        DownloadPanel.Chunks.Add(new ChunkInfo
        {
            Start = start,
            End = end,
            Progress = 0.0
        });
    }
}