BetterHexViewer.WinUI3 1.1.5

dotnet add package BetterHexViewer.WinUI3 --version 1.1.5
                    
NuGet\Install-Package BetterHexViewer.WinUI3 -Version 1.1.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BetterHexViewer.WinUI3" Version="1.1.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BetterHexViewer.WinUI3" Version="1.1.5" />
                    
Directory.Packages.props
<PackageReference Include="BetterHexViewer.WinUI3" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BetterHexViewer.WinUI3 --version 1.1.5
                    
#r "nuget: BetterHexViewer.WinUI3, 1.1.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BetterHexViewer.WinUI3@1.1.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BetterHexViewer.WinUI3&version=1.1.5
                    
Install as a Cake Addin
#tool nuget:?package=BetterHexViewer.WinUI3&version=1.1.5
                    
Install as a Cake Tool

BetterHexViewer.WinUI3

BetterHexViewer icon

NuGet Build MIT License

BetterHexViewer.WinUI3 is a feature-rich, fully customisable hex-viewer control for Windows App SDK / WinUI 3 applications. All rendering is GPU-accelerated via Win2D (CanvasControl) — a single DrawingSession replaces thousands of XAML elements, delivering smooth scrolling even on 4K displays with files of any size.


Features

Feature Detail
GPU-accelerated rendering Win2D CanvasControl — one DrawingSession per frame, ~2 ms CPU at 4K
Large-file support MemoryMappedFile — no size limit, tested up to 84 GB; scroll works beyond 2 GB
Mouse selection Click-drag in hex or ASCII panels; both stay in sync
Keyboard navigation Arrow keys, Home/End, PgUp/PgDn, Shift-extend selection, Ctrl+A
Text and byte search SearchAsync / SearchNextAsync / SearchPreviousAsync / FindAllAsync
Programmatic selection SelectRange(offset, length) and SelectFromTo(start, end)
Hover cross-highlight 1 px border tracks the pointer in both panels simultaneously
Context menu Right-click to copy selection as hex string or ASCII text
Offset formats Hexadecimal · Decimal · Octal
Column grouping 1 · 2 · 4 · 8 · 16 bytes per visual group
Full-width auto-fit FullWidth = true adapts column count to the available width
Configurable spacing BytesSpacing and ExtraLineGap in pixels
ASCII encoding AsciiEncoding — Latin-1 (default), IBM CP437, UTF-8, CP1252, any Encoding
ASCII panel Toggleable via ShowAsciiPanel
Font control FontFamily, FontSize, FontWeight — hot-reloadable at runtime
Colour themes All brushes are bindable — background, foreground, offsets, ruler, selection, dividers
Tooltip 500 ms hover tooltip showing offset and byte value
SelectionChanged event StartOffset, Length, full byte[] (no length cap on the property)
ScrollToOffset Scroll to any byte offset programmatically

Requirements

Component Minimum version
Windows App SDK 1.8
Target OS Windows 10 19041 (20H1)
.NET 8.0
Win2D Microsoft.Graphics.Win2D 1.3.0

Quick start

1 — Install the NuGet package

dotnet add package BetterHexViewer.WinUI3

2 — Add the XAML namespace

xmlns:hex="using:BetterHexViewer.WinUI3"

3 — Place the control

<hex:BetterHexViewer
    x:Name="HexViewer"
    OffsetFormat="Hexadecimal"
    ColumnGroupSize="One"
    BytesSpacing="10"
    ExtraLineGap="4"
    FullWidth="False"
    ShowAsciiPanel="True"
    SelectionChanged="HexViewer_SelectionChanged"/>

4 — Load content

// From a file (any size — uses MemoryMappedFile)
await HexViewer.OpenFileAsync(filePath);

// From a byte array
HexViewer.LoadBytes(myByteArray);
// Text search (forward)
var result = await HexViewer.SearchAsync("MZ");

// Byte-sequence search
var result = await HexViewer.SearchAsync(new byte[] { 0x4D, 0x5A });

// Navigate results
await HexViewer.SearchNextAsync();
await HexViewer.SearchPreviousAsync();

// Find all occurrences
IReadOnlyList<long> offsets = await HexViewer.FindAllAsync("MZ");

6 — Programmatic selection

// Select 16 bytes starting at offset 0x100
HexViewer.SelectRange(0x100, 16);

// Select from offset 0x200 to 0x2FF (inclusive)
HexViewer.SelectFromTo(0x200, 0x2FF);

7 — Change ASCII encoding

// Enable extended code pages (call once at app startup)
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

HexViewer.AsciiEncoding = Encoding.GetEncoding(437); // IBM CP437
HexViewer.AsciiEncoding = Encoding.UTF8;

Properties

Layout and display

Property Type Default Description
OffsetFormat OffsetFormat Hexadecimal Format of the offset column
ColumnGroupSize ColumnGroupSize One Bytes per visual group
BytesSpacing double 10 Horizontal gap between hex columns (px)
ExtraLineGap double 4 Extra vertical gap between rows (px)
FullWidth bool false Auto-fit columns to available width
ShowAsciiPanel bool true Show or hide the ASCII panel
AsciiEncoding Encoding Latin-1 Encoding used in the ASCII panel
BytesPerLine (read-only) int 16 Current number of columns
FileSize (read-only) long 0 Size of loaded data in bytes

Font

Property Type Default Description
FontFamily FontFamily Courier New Monospaced font family
FontSize double 13 Font size in points
FontWeight FontWeight Normal Font weight

Colours

Property Type Default Description
Background Brush Theme Control background
Foreground Brush Theme Hex and ASCII data text
OffsetForeground Brush Dark blue Offset column text
OffsetBackground Brush Theme Offset column background
AsciiBackground Brush Theme ASCII panel background
RulerForeground Brush? auto Ruler header text
SelectionBackground Brush Blue Selection highlight background
SelectionForeground Brush White Selected byte text
DividerBrush Brush Gray Column divider lines

Methods

Method Description
OpenFileAsync(string path) Opens a file of any size via MemoryMappedFile
LoadBytes(byte[] data) Loads raw bytes directly
Clear() Clears the viewer
CopySelectionAsHex() Copies selection to clipboard as space-separated hex pairs
CopySelectionAsAscii() Copies selection to clipboard as ASCII text
ScrollToOffset(long offset) Scrolls to the row containing the given byte offset
SelectRange(long offset, long length) Programmatically selects length bytes from offset
SelectFromTo(long start, long end) Selects bytes between two offsets (inclusive, any order)
SearchAsync(byte[]) Searches forward for a byte pattern
SearchAsync(string, Encoding?) Searches forward for a text pattern
SearchNextAsync() Finds the next match
SearchPreviousAsync() Finds the previous match
FindAllAsync(byte[]) Returns offsets of all non-overlapping matches
FindAllAsync(string, Encoding?) Returns offsets of all text matches
ClearSearch() Clears search state and selection
ApplyTheme() Re-applies light/dark colour defaults
Dispose() Releases the memory-mapped file handle

Events

// Fired when the selection changes
HexViewer.SelectionChanged += (sender, e) =>
{
    long   offset = e.StartOffset; // -1 when no selection
    long   length = e.Length;
    byte[] data   = e.Data;        // full copy, no size cap
};

// Fired after each SearchAsync / SearchNextAsync / SearchPreviousAsync
HexViewer.SearchResultFound += (sender, result) =>
{
    bool found   = result.Found;
    long offset  = result.Offset;  // -1 when not found
    long length  = result.Length;
    bool wrapped = result.Wrapped;
};

Enumerations

public enum OffsetFormat    { Hexadecimal, Decimal, Octal }
public enum ColumnGroupSize { One = 1, Two = 2, Four = 4, Eight = 8, Sixteen = 16 }

Building from source

git clone https://github.com/zipgenius/BetterHexViewer_WinUI3.git
cd BetterHexViewer.WinUI3
dotnet restore
dotnet build -c Release -p:Platform=x64

Run the demo:

dotnet run --project BetterHexViewer.Demo -c Debug -p:Platform=x64

Create a NuGet package:

dotnet pack BetterHexViewer.WinUI3/BetterHexViewer.WinUI3.csproj -c Release -p:Platform=x64 -o nupkg

Changelog

See CHANGELOG.md.


License

MIT © zipgenius.it — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0-windows10.0.26100 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.5 40 3/12/2026