wpfmasonry 3.0.2611.1
dotnet add package wpfmasonry --version 3.0.2611.1
NuGet\Install-Package wpfmasonry -Version 3.0.2611.1
<PackageReference Include="wpfmasonry" Version="3.0.2611.1" />
<PackageVersion Include="wpfmasonry" Version="3.0.2611.1" />
<PackageReference Include="wpfmasonry" />
paket add wpfmasonry --version 3.0.2611.1
#r "nuget: wpfmasonry, 3.0.2611.1"
#:package wpfmasonry@3.0.2611.1
#addin nuget:?package=wpfmasonry&version=3.0.2611.1
#tool nuget:?package=wpfmasonry&version=3.0.2611.1
WPF Masonry
A fluid, "Windows 8 tile"–style layout grid for WPF. Arranges variable-sized children into a tightly packed, gap-filling layout that reflows as items are added, removed, or resized.
Targets .NET 10 (net10.0-windows), .NET 11 (net11.0-windows) and .NET Framework 4.6.2 (net462).
Install
dotnet add package wpfmasonry
Usage
Add the namespace and drop a MasonryControl into your XAML. It is an ItemsControl, so populate it with child FrameworkElements directly or via ItemsSource.
<Window xmlns:masonry="clr-namespace:Masonry;assembly=Masonry">
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<masonry:MasonryControl Spacing="5" Background="#E3E3E3">
<Border Width="200" Height="120" Background="SteelBlue" />
<Border Width="200" Height="260" Background="IndianRed" />
<Border Width="200" Height="160" Background="SeaGreen" />
</masonry:MasonryControl>
</ScrollViewer>
</Window>
Binding items (MVVM)
Bind ItemsSource to a collection of FrameworkElements. Use an ObservableCollection so the layout reflows automatically as items change:
public ObservableCollection<FrameworkElement> Elements { get; } = new();
Elements.Add(new Border
{
Width = 200,
Height = 180,
Background = Brushes.SteelBlue
});
<masonry:MasonryControl ItemsSource="{Binding Elements}" Spacing="5" />
Children must derive from
FrameworkElement; anything else throwsInvalidDataException. Give each child an explicitWidth/Height(or a size-determining content) so the packer can measure it.
Animated layout
AnimatedMasonryControl is a drop-in replacement that animates tiles gliding to their new positions instead of snapping. Set AnimationDuration to control the glide:
<masonry:AnimatedMasonryControl ItemsSource="{Binding Elements}"
Spacing="5"
AnimationDuration="0:0:2" />
Properties
| Control | Property | Type | Description |
|---|---|---|---|
MasonryControl |
Spacing |
int |
Gap (px) added around each child during packing. |
AnimatedMasonryControl |
AnimationDuration |
Duration |
Length of the reposition animation. |
AnimatedMasonryControl also exposes the underlying AnimationManager for advanced scenarios.
How it works
Children are laid out by tracking the open horizontal spans (a free-space "matrix") and placing each child in the shallowest span wide enough to hold it. Positions are applied via Margin, and a relayout is triggered on items changes, item-source changes, render-size changes, and child desired-size changes.
See the Masonry.Example project in the repository for a complete runnable sample.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. net10.0-windows10.0.18362 is compatible. net11.0-windows7.0 is compatible. net11.0-windows10.0.18362 is compatible. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- No dependencies.
-
net10.0-windows10.0.18362
- No dependencies.
-
net10.0-windows7.0
- No dependencies.
-
net11.0-windows10.0.18362
- No dependencies.
-
net11.0-windows7.0
- No dependencies.
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 |
|---|---|---|
| 3.0.2611.1 | 108 | 11/17/2026 |
| 3.0.2503.131 | 1,277 | 3/13/2025 |
| 3.0.2412.11 | 495 | 12/1/2024 |
| 3.0.2406.22 | 261 | 6/2/2024 |
| 2.0.2010.1215 | 2,195 | 10/12/2020 |
| 1.0.0 | 1,742 | 7/18/2018 |
Updated to work with .NET 10.0