SankeyDiagramControl.SelectedItems Property
Gets or sets the collection of selected Sankey links and nodes.
Namespace: DevExpress.Xpf.Charts.Sankey
Assembly: DevExpress.Xpf.Charts.v24.1.dll
NuGet Package: DevExpress.Wpf.Charts
Declaration
Property Value
Type | Description |
---|---|
IList | The collection of selected Sankey links and nodes. |
Remarks
Add links and nodes to the SelectedItems collection to select them. When you use the SelectedItems property to change the Sankey element selection, the SankeyDiagramControl ignores whether the selection is enabled in the SelectionMode property.
The following example selects the France node and the related links:
<Window
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
xmlns:dxsa="http://schemas.devexpress.com/winfx/2008/xaml/sankey"
x:Class="WpfApp1.MainWindow"
mc:Ignorable="d"
Title="MainWindow">
<Grid>
<dxsa:SankeyDiagramControl x:Name="sankeyDiagramControl1"
DataSource="{Binding Data}"
SelectedItems="{Binding SelectedSankeyItems}"
SourceDataMember="Source"
TargetDataMember="Target"
WeightDataMember="Value">
<!--...-->
<dxsa:SankeyDiagramControl.DataContext>
<local:SankeyViewModel/>
</dxsa:SankeyDiagramControl.DataContext>
</dxsa:SankeyDiagramControl>
</Grid>
</Window>
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows;
using DevExpress.Xpf.Charts.Sankey;
namespace WpfApp1 {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
}
public class SankeyViewModel : INotifyPropertyChanged {
IList<object> selectedSankeyItems;
List<SankeyItem> data;
public List<SankeyItem> Data {
get {
if (data == null)
data = GetData();
return data;
}
}
public IList<object> SelectedSankeyItems {
get { return selectedSankeyItems; }
set {
if (selectedSankeyItems != value) {
if (selectedSankeyItems is ObservableCollection<object>)
((ObservableCollection<object>)selectedSankeyItems).CollectionChanged -= SelectedSankeyItems_CollectionChanged;
selectedSankeyItems = value;
if (selectedSankeyItems is ObservableCollection<object>)
((ObservableCollection<object>)selectedSankeyItems).CollectionChanged += SelectedSankeyItems_CollectionChanged;
OnPropertyChanged("SelectedSankeyItems");
}
}
}
public SankeyViewModel() {
ObservableCollection<object> collection = new ObservableCollection<object>();
collection.CollectionChanged += SelectedSankeyItems_CollectionChanged;
selectedSankeyItems = collection;
selectedSankeyItems.Add("France");
selectedSankeyItems.Add(Data[0]);
selectedSankeyItems.Add(Data[2]);
selectedSankeyItems.Add(Data[5]);
}
public event PropertyChangedEventHandler PropertyChanged;
void SelectedSankeyItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
}
void OnPropertyChanged(string propertyName) {
PropertyChangedEventHandler propertyChangedEventHendler = PropertyChanged;
if (propertyChangedEventHendler != null)
propertyChangedEventHendler(this, new PropertyChangedEventArgs(propertyName));
}
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