Back to Devexpress

HeatmapControl.SelectedItems Property

wpf-devexpress-dot-xpf-dot-charts-dot-heatmap-dot-heatmapcontrol-ec6e9b0c.md

latest4.7 KB
Original Source

HeatmapControl.SelectedItems Property

Gets or sets heatmap cells or source objects that are used to create the selected cells.

Namespace : DevExpress.Xpf.Charts.Heatmap

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

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
[NonCategorized]
public IList SelectedItems { get; set; }
vb
<NonCategorized>
Public Property SelectedItems As IList

Property Value

TypeDescription
IList

A list of objects that store cell data.

|

Remarks

If the heatmap is bound to a data source, the SelectedItems property returns the data objects assigned to the selected cells. Otherwise, the selected cell objects are returned.

Use the HeatmapControl.SelectedItem property to obtain the last selected cell.

Example

The following example shows how to use heatmap selected cell data as a source for another chart:

xaml
<dxh:HeatmapControl x:Name="heatmap" 
                    Grid.Row="0" Margin="10" 
                    SelectionMode="Multiple"
                    SelectedItems="{Binding SelectedSales, Mode=TwoWay}" 
                    ToolTipEnabled="True">
    <dxh:HeatmapDataSourceAdapter
        DataSource="{Binding Sales}"
        XArgumentDataMember="Month"
        YArgumentDataMember="Product"
        XArgumentComparer="{local:SaveOrderComparer}"
        ColorDataMember="RevenueByMonth"/>
        <!--...-->
</dxh:HeatmapControl>

<dxc:ChartControl x:Name="chart" Grid.Row="1"
    DataSource="{Binding SelectedSales, Converter={local:SelectedItemsToDataSourceConverter}}" 
    BorderBrush="Transparent">
    <!--...-->
</dxc:ChartControl>
csharp
public class InteractionViewModel : BindableBase {
    //...

    readonly List<ProductSale> sales;
    ObservableCollection<object> selectedSales;

    public List<ProductSale> Sales { get { return sales; } }
    public virtual ObservableCollection<object> SelectedSales {
        get { return selectedSales; }
        set {
            if (selectedSales == value)
                return;
            selectedSales = value;
            if (selectedSales != null)
                selectedSales.CollectionChanged += (s, e) => RaisePropertyChanged("SelectedSales");
            RaisePropertyChanged("SelectedSales");
        }
    }
    protected InteractionViewModel() {
        sales = LoadData();
        SelectedSales = new ObservableCollection<object>() { sales[0] };
    }
    //...
}
vb
Public Class InteractionViewModel
        Inherits DevExpress.Mvvm.BindableBase
        '...
        Private ReadOnly salesField As System.Collections.Generic.List(Of TreeMapDemo.ProductSale)

        Private selectedSalesField As System.Collections.ObjectModel.ObservableCollection(Of Object)

        Public ReadOnly Property Sales As List(Of TreeMapDemo.ProductSale)
            Get
                Return Me.salesField
            End Get
        End Property

        Public Overridable Property SelectedSales As ObservableCollection(Of Object)
            Get
                Return Me.selectedSalesField
            End Get

            Set(ByVal value As ObservableCollection(Of Object))
                If Me.selectedSalesField Is value Then Return
                Me.selectedSalesField = value
                If Me.selectedSalesField IsNot Nothing Then AddHandler Me.selectedSalesField.CollectionChanged, Sub(s, e) Me.RaisePropertyChanged("SelectedSales")
                Me.RaisePropertyChanged("SelectedSales")
            End Set
        End Property

        Protected Sub New()
            Me.salesField = Me.LoadData()
            Me.SelectedSales = New System.Collections.ObjectModel.ObservableCollection(Of Object)() From {Me.salesField(0)}
        End Sub
        ' ...
    End Class

For a complete source code, see the Selection demo:

Run Demo

See Also

HeatmapControl Class

HeatmapControl Members

DevExpress.Xpf.Charts.Heatmap Namespace