# diagram-organization-chart

> Organization chart using Diagram with hierarchical ViewModel and HierarchicalTree layout.

**Framework:** wpf  **Component:** Diagram  **Variant:** organization-chart

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/wpf/diagram-organization-chart.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.SfDiagram.WPF
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/diagram-organization-chart/Diagram.xaml

```xaml
<UserControl
    x:Class="OrganizationChart.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
    xmlns:local="clr-namespace:OrganizationChart"
    mc:Ignorable="d"
    d:DesignHeight="450" d:DesignWidth="800">

    <UserControl.DataContext>
        <local:OrganizationChartDataSource />
    </UserControl.DataContext>

    <UserControl.Resources>
        <ResourceDictionary>
            
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Syncfusion.SfDiagram.WPF;component/Resources/BasicShapes.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <local:SelectedBorderConverter x:Key="SelectedBorderConverter" />

            <!-- Template that renders a single employee card. -->
            <DataTemplate x:Key="EmployeeCardTemplate">
                <Border Width="170" Height="50" BorderThickness="1"
                        Background="{Binding RatingColor}"
                        CornerRadius="6" BorderBrush="LightGray">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Border Grid.Column="0" VerticalAlignment="Stretch"
                                Background="Transparent" BorderBrush="#FF5DC3B1"
                                CornerRadius="6" Padding="5">
                            <Image HorizontalAlignment="Center"
                                   Source="{Binding ImageUrl}"
                                   Stretch="Uniform" />
                        </Border>

                        <Grid Grid.Column="1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="25" />
                                <RowDefinition Height="25" />
                            </Grid.RowDefinitions>

                            <TextBlock Grid.Row="0" Margin="10,0,0,0"
                                       HorizontalAlignment="Left" VerticalAlignment="Center"
                                       FontFamily="Segoe UI" FontSize="12" FontWeight="Bold"
                                       Foreground="White" Text="{Binding Name}" />

                            <TextBlock Grid.Row="1" Margin="10,0,0,0"
                                       HorizontalAlignment="Left" VerticalAlignment="Top"
                                       FontFamily="Segoe UI" FontSize="11" FontWeight="SemiBold"
                                       Foreground="White" Text="{Binding Designation}" />
                        </Grid>
                    </Grid>
                </Border>
            </DataTemplate>

            <Style x:Key="ButtonStyle" TargetType="Button">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border BorderThickness="2" Background="{TemplateBinding Background}">
                                <Border.BorderBrush>
                                    <MultiBinding Converter="{StaticResource SelectedBorderConverter}">
                                        <Binding Path="DataContext.SelectedLayout" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                                        <Binding Path="CommandParameter" RelativeSource="{RelativeSource TemplatedParent}" />
                                    </MultiBinding>
                                </Border.BorderBrush>
                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="{TemplateBinding Padding}" />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="syncfusion:Node">
                <Setter Property="ContentTemplate" Value="{StaticResource EmployeeCardTemplate}" />
                <Setter Property="UnitHeight" Value="50" />
                <Setter Property="UnitWidth" Value="170" />
            </Style>

            <Style TargetType="syncfusion:Connector">
                <Setter Property="ConnectorGeometryStyle">
                    <Setter.Value>
                        <Style TargetType="Path">
                            <Setter Property="Stroke" Value="#FFBABABA" />
                            <Setter Property="StrokeThickness" Value="1" />
                        </Style>
                    </Setter.Value>
                </Setter>
                <Setter Property="TargetDecoratorStyle">
                    <Setter.Value>
                        <Style TargetType="Path">
                            <Setter Property="Height" Value="0" />
                            <Setter Property="Width" Value="0" />
                        </Style>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <syncfusion:SfDiagram x:Name="diagramControl"
                              Grid.Column="0"
                              Margin="5"
                              DefaultConnectorType="{Binding DefaultConnectorType}"
                              Constraints="{Binding Constraints}"
                              ItemAddedCommand="{Binding ItemAddedCommand}"
                              GetLayoutInfoCommand="{Binding GetLayoutInfoCommand}"
                              Nodes="{Binding Nodes}"
                              Connectors="{Binding Connectors}"
                              DataSourceSettings="{Binding DataSourceSettings}"
                              LayoutManager="{Binding LayoutManager}"
                              Menu="{Binding Menu}"
                              Tool="{Binding Tool}">

            <syncfusion:SfDiagram.ScrollSettings>
                <syncfusion:ScrollSettings ScrollLimit="Diagram" />
            </syncfusion:SfDiagram.ScrollSettings>

            <syncfusion:SfDiagram.PageSettings>
                <syncfusion:PageSettings PageBorderBrush="White" PageBackground="White" />
            </syncfusion:SfDiagram.PageSettings>
        </syncfusion:SfDiagram>

        <StackPanel Grid.Column="1" Margin="15,5,15,0" MinWidth="170">
            <TextBlock Text="Options" FontFamily="Segoe UI" FontSize="16" Margin="0,0,0,10" />
            <TextBlock Text="Vertical" FontFamily="Segoe UI" FontWeight="SemiBold" FontSize="12" />
            <StackPanel Orientation="Horizontal">
                <Button x:Name="orgCompactAlternate" Margin="0,10,0,0" Background="White" ToolTip="Vertical and Alternate"
                        Style="{StaticResource ButtonStyle}" Command="{Binding LayoutCommand}" CommandParameter="alternate">
                    <Grid Width="50" Height="50">
                        <Path Data="F1M80,130L87,130L87,124L80,124z" Fill="#FF5C9BD3" Stretch="Fill" Margin="21,12,22,0" Height="6" VerticalAlignment="Top" />
                        <Path Data="F1M84,146L84,138L89,138L89,137L84,137L84,130L83,130L83,137L77,137L77,138L83,138L83,146L78,146L78,147L83,147L84,147L90,147L90,146z" Fill="DimGray" Stretch="Fill" Margin="18,18,19,15" />
                        <Path Data="M18.000002,9.0000019 L25.000002,9.0000019 L25.000002,16.000002 L18.000002,16.000002 z M0,9.000001 L7,9.000001 L7,16 L0,16 z M18,0 L25,0 L25,7 L18,7 z M0,0 L7,0 L7,7 L0,7 z" Fill="#FF808181" Margin="12,22,13,12" Stretch="Fill" />
                    </Grid>
                </Button>
                <Button x:Name="orgCompactRight" Margin="10,10,0,0" Background="White" ToolTip="Vertical and Right"
                        Style="{StaticResource ButtonStyle}" Command="{Binding LayoutCommand}" CommandParameter="right">
                    <Grid Width="50" Height="50">
                        <Path Data="F1M213,336L206,336L206,330L213,330z" Fill="#FF5C9BD3" Height="6" Stretch="Fill" Margin="17,12,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="7" />
                        <Path Data="F1M209,352L209,344L209,343L209,336L210,336L210,343L216,343L216,344L210,344L210,352L215,352L215,353L210,353L209,353z" Fill="DimGray" Stretch="Fill" Margin="20,18,23,15" />
                        <Path Data="F1M222,347L215,347L215,340L222,340z" Fill="#FF808181" Stretch="Fill" Margin="0,22,17,21" HorizontalAlignment="Right" Width="7" />
                        <Path Data="F1M222,356L215,356L215,349L222,349z" Fill="#FF808181" Height="7" Stretch="Fill" Margin="0,0,17,12" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="7" />
                    </Grid>
                </Button>
                <Button x:Name="orgCompactLeft" Margin="10,10,0,0" Background="White" ToolTip="Vertical and Left"
                        Style="{StaticResource ButtonStyle}" Command="{Binding LayoutCommand}" CommandParameter="left">
                    <Grid Width="50" Height="50">
                        <Path Data="F1M145,336L152,336L152,330L145,330z" Fill="#FF5C9BD3" Height="6" Stretch="Fill" Margin="0,12,17,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="7" />
                        <Path Data="F1M149,352L149,344L149,343L149,336L148,336L148,343L142,343L142,344L148,344L148,352L143,352L143,353L148,353L149,353z" Fill="DimGray" Stretch="Fill" Margin="23,18,20,15" />
                        <Path Data="F1M136,347L143,347L143,340L136,340z" Fill="#FF808181" Stretch="Fill" Margin="17,22,0,21" HorizontalAlignment="Left" Width="7" />
                        <Path Data="F1M136,356L143,356L143,349L136,349z" Fill="#FF808181" Height="7" Stretch="Fill" Margin="17,0,0,12" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="7" />
                    </Grid>
                </Button>
            </StackPanel>

            <TextBlock Text="Horizontal" Margin="0,10,0,0" FontFamily="Segoe UI" FontWeight="SemiBold" FontSize="12" />
            <StackPanel Orientation="Horizontal">
                <Button x:Name="orgCompactCenter" Margin="0,10,0,0" Background="White" ToolTip="Horizontal And Alternate"
                        Style="{StaticResource ButtonStyle}" Command="{Binding LayoutCommand}" CommandParameter="horizontal_center">
                    <Grid Width="50" Height="50">
                        <Path Data="F1M121,62L128,62L128,56L121,56z" Fill="#FF5C9BD3" Height="6" Stretch="Fill" Margin="21,12,22,0" VerticalAlignment="Top" />
                        <Path Data="M0,6.999999 L1,6.999999 L20,6.999999 L21,6.999999 L21,12.999999 L20,12.999999 L20,7.999999 L1,7.999999 L1,12.999999 L0,12.999999 z M10.000001,0 L11.000001,0 L11.000001,6.9990001 L10.000001,6.9990001 z" Fill="DimGray" Stretch="Fill" Margin="14,18,15,19" />
                        <Path Data="M20.000002,1.2069941E-06 L27.000002,1.2069941E-06 L27.000002,7.000001 L20.000002,7.000001 z M0,0 L7,0 L7,7 L0,7 z" Fill="#FF808181" Height="7" Stretch="Fill" Margin="11,0,12,12" VerticalAlignment="Bottom" />
                    </Grid>
                </Button>
                <Button x:Name="orgCompactHorizontalRight" Margin="10,10,0,0" Background="White" ToolTip="Horizontal And Right"
                        Style="{StaticResource ButtonStyle}" Command="{Binding LayoutCommand}" CommandParameter="horizontal_right">
                    <Grid Width="50" Height="50">
                        <Path Data="F1M209,68L215,68L215,61L209,61z" Fill="#FF5C9BD3" Height="7" Stretch="Fill" Width="6" HorizontalAlignment="Left" Margin="12,17,0,0" VerticalAlignment="Top" />
                        <Path Data="F1M231,64L223,64L222,64L215,64L215,65L222,65L222,71L223,71L223,65L231,65L231,70L232,70L232,65L232,64z" Fill="DimGray" Stretch="Fill" Margin="18,20,15,23" />
                        <Path Data="M0,9.5367443E-07 L7,9.5367443E-07 L7,7.000001 L0,7.000001 z M9.0000029,0 L16.000002,0 L16.000002,6.9999995 L9.0000029,6.9999995 z" Fill="#FF808181" Height="7" Margin="22,0,12,17" Stretch="Fill" VerticalAlignment="Bottom" />
                    </Grid>
                </Button>
                <Button x:Name="orgCompactHorizontalLeft" Margin="10,10,0,0" Background="White" ToolTip="Horizontal And Left"
                        Style="{StaticResource ButtonStyle}" Command="{Binding LayoutCommand}" CommandParameter="horizontal_left">
                    <Grid Width="50" Height="50">
                        <Path Data="F1M325,68L319,68L319,61L325,61z" Fill="#FF5C9BD3" Height="7" Stretch="Fill" Margin="0,17,12,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="6" />
                        <Path Data="F1M303,64L311,64L312,64L319,64L319,65L312,65L312,71L311,71L311,65L303,65L303,70L302,70L302,65L302,64z" Fill="DimGray" Stretch="Fill" Margin="15,20,18,23" />
                        <Path Data="M0,4.7683722E-07 L6.9999995,4.7683722E-07 L6.9999995,7 L0,7 z M9.000001,0 L16,0 L16,7 L9.000001,7 z" Fill="#FF808181" Height="7" Margin="12,0,22,17" Stretch="Fill" VerticalAlignment="Bottom" />
                    </Grid>
                </Button>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>
```
