How to: Implement a Custom Layout Algorithm

  • 4 minutes to read

To implement a custom layout algorithm, design a class inheriting the abstract TreeMapLayoutAlgorithm class and implement its TreeMapLayoutAlgorithmBase.Calculate method, which will calculate item layouts using a custom algorithm.

In this example, items are arranged depending on the empty space width/height ratio.

View Example

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes

Namespace CustomLayoutAlgorithmSample
    ''' <summary>
    ''' Interaction logic for MainWindow.xaml
    ''' </summary>
    Partial Public Class MainWindow
        Inherits Window

        Public Sub New()
        End Sub
    End Class
End Namespace