Click or drag to resize
AB4D logo

ReaderSvgGetLayerNames Method

Returns a List of layer names that were defined in Microsoft Visio.

Namespace:  Ab2d
Assembly:  Ab2d.ReaderSvg (in Ab2d.ReaderSvg.dll) Version: 7.1.7295.1040
public List<string> GetLayerNames()

Return Value

Type: ListString
List of layer names that were defined in Microsoft Visio.

Ab2d.ReaderSvg has some methods that are specialized to read additional data from svg files that were created with Microsoft Visio.

It is possible to get the data about the layers and custom properties and data.

To get information about the layers use GetLayerNames or GetElementsForLayerName(String).

To get custom properties and associated data use:


The following code is taken from OfficePlanSample and shows how to fill a LayersPanel with checkboxes - one for each layer defined in svg file. With checking or unchecking the checkboxes the elements associated to the layer are shown or hidden. The svg file is read with SvgViewbox that is defined in xaml.

private void CollectLayers(Ab2d.ReaderSvg readerSvg)
    List<string> layers;

    // Get names of the layers defined in Visio
    // SvgOfficePlan is a SvgViewbox control defined in XAML
    layers = SvgOfficePlan.InnerReaderSvg.GetLayerNames();

    foreach (string oneLayerName in layers)
        CheckBox newCheckBox;

        // Create a checkbox for each layer
        newCheckBox = new CheckBox();
        newCheckBox.Content = oneLayerName;
        newCheckBox.IsChecked = true;
        newCheckBox.Checked += new RoutedEventHandler(LayerRadioButton_Checked);
        newCheckBox.Unchecked += new RoutedEventHandler(LayerRadioButton_Checked);

        // Fill LayersPanel with checkboxes

void LayerRadioButton_Checked(object sender, RoutedEventArgs e)
    string layerName;
    CheckBox changedCheckBox;

    changedCheckBox = (CheckBox)sender;

    layerName = (string)changedCheckBox.Content;

    // Show or hide all elements in the layer
    ShowHideLayerElements(layerName, changedCheckBox.IsChecked ?? false);

private void ShowHideLayerElements(string layerName, bool isVisible)
    List<UIElement> elementsForLayerName;

    // Get all UIElements that are connected to specified layer
    elementsForLayerName = SvgOfficePlan.InnerReaderSvg.GetElementsForLayerName(layerName);

    // TODO:
    // Because one object can be in multiple layers 
    // we should check that when showing an object 
    // all the layers for the objects should be visible

    foreach (UIElement oneElement in elementsForLayerName)
        if (isVisible)
            oneElement.Visibility = Visibility.Visible;
            oneElement.Visibility = Visibility.Collapsed;

public List<string> GetLayerNames()
    if (!Ab.Common.Licensing.ReaderSvg.CommonLicensing.IsCalledFromWellKnowApplication())

    if (_visioLayers == null)
        return null;
        return _visioLayers.GetLayerNames();
<svg:SvgViewbox Name="SvgOfficePlan" Source="Resources/Office plan.svg"/>
See Also