Skip to main content
A newer version of this page is available. .
All docs
V20.2

SankeyDiagramControl.HighlightedItems Property

Gets or sets the collection of data objects that are used to create highlighted links and nodes.

Namespace: DevExpress.Xpf.Charts.Sankey

Assembly: DevExpress.Xpf.Charts.v20.2.dll

NuGet Packages: DevExpress.WindowsDesktop.Wpf.Charts, DevExpress.Wpf.Charts

Declaration

[NonCategorized]
public IList HighlightedItems { get; set; }

Property Value

Type Description
IList

The collection of of data objects that are used to create highlighted links and nodes.

Remarks

The following example highlights an item and displays the highlighted item in a label:

<Window
    x:Class="WpfApplication2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:dxsa="http://schemas.devexpress.com/winfx/2008/xaml/sankey"
    xmlns:local="clr-namespace:WpfApplication2"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Width="640"
    Height="420"
    mc:Ignorable="d"
    Title="MainWindow">
    <Window.DataContext>
        <local:SankeyViewModel />
    </Window.DataContext>
    <Grid>
        <dxsa:SankeyDiagramControl
            x:Name="sankeyDiagramControl1"
            DataSource="{Binding Data}"
            HighlightedItems="{Binding HighlightedItems}"
            SourceDataMember="Source"
            TargetDataMember="Target"
            WeightDataMember="Value">
            <dxsa:SankeyDiagramControl.Titles>
                <dxsa:SankeyTitle HorizontalAlignment="Center" Content="Export/Import" />
            </dxsa:SankeyDiagramControl.Titles>
        </dxsa:SankeyDiagramControl>
        <Button
            Margin="0,0,140,10"
            HorizontalAlignment="Right"
            VerticalAlignment="Bottom"
            Command="{Binding HighlightCommand}"
            Content="Highlight 'France'" />
        <Label Content="{Binding HighlightedItem}"
            HorizontalAlignment="Right"
            HorizontalContentAlignment="Left"
            VerticalAlignment="Bottom" Margin="0,0,30,10" Width="105"/>

    </Grid>
</Window>
public class SankeyViewModel : ViewModelBase {
    readonly ObservableCollection<object> highlightedItems;

    public object HighlightedItem {
        get {
            string text = string.Empty;
            if(highlightedItems.Count > 0) {
                if(highlightedItems[0] is SankeyItem)
                    text = ((SankeyItem)highlightedItems[0]).Value.ToString();
                else
                    text = highlightedItems[0].ToString();
            }
            else
                text = "(none)";
            return "Current: " + text;
        }
    }
    public ObservableCollection<object> HighlightedItems { get { return highlightedItems; } }
    public DelegateCommand HighlightCommand { get; private set; }
    public List<SankeyItem> Data {
        get { return GetData(); }
    }

    public SankeyViewModel() {
        HighlightCommand = new DelegateCommand(HighlightCommandExecute, HighlightCommandCanExecute);
        highlightedItems = new ObservableCollection<object>();
        highlightedItems.CollectionChanged += HighlightedItems_CollectionChanged;
    }
    void HighlightedItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
        RaisePropertyChanged("HighlightedItem");
    }
    bool HighlightCommandCanExecute() {
        return true;
    }
    void HighlightCommandExecute() {
        highlightedItems.Clear();
        highlightedItems.Add("France");
    }
    public List<SankeyItem> GetData() {
        List<SankeyItem> data = new List<SankeyItem>{
            new SankeyItem { Source = "France", Target = "UK", Value = 53 },
            new SankeyItem { Source = "Australia", Target = "UK", Value = 72 },
            new SankeyItem { Source = "France", Target = "Canada", Value = 81 },
            new SankeyItem { Source = "China", Target = "Canada", Value = 96 },
            new SankeyItem { Source = "UK", Target = "France", Value = 61 },
            new SankeyItem { Source = "Canada", Target = "France", Value = 89 }
        };
        return data;
    }
}

public class SankeyItem {
    public string Source { get; set; }
    public string Target { get; set; }
    public double Value { get; set; }
}
See Also