Dashboard.ItemCollectionChanged Event
Occurs after the collection of dashboard items has been changed.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v22.2.Core.dll
NuGet Packages: DevExpress.Dashboard.Core, DevExpress.Win.Dashboard.Design
Declaration
public event EventHandler<NotifyingCollectionChangedEventArgs<DashboardItem>> ItemCollectionChanged
Event Data
The ItemCollectionChanged event's data class is NotifyingCollectionChangedEventArgs<DashboardItem>. The following properties provide information specific to this event:
Property | Description |
---|---|
AddedItems | Gets items added to the NotifyingCollection<T>. |
RemovedItems | Gets items removed from the NotifyingCollection<T>. |
Remarks
The ItemCollectionChanged event is raised after dashboard items are added to or removed from the Dashboard.Items collection.
Use the event parameter’s NotifyingCollectionChangedEventArgs`1.AddedItems and NotifyingCollectionChangedEventArgs`1.RemovedItems properties to determine which dashboard items have been added or removed, respectively.
The following code logs the DashboardItem information when a DashboardItem is added, deleted or duplicated.
private void DashboardDesigner1_DashboardLoaded(object sender, DevExpress.DashboardWin.DashboardLoadedEventArgs e)
{
e.Dashboard.ItemCollectionChanged += Dashboard_ItemCollectionChanged;
}
private void Dashboard_ItemCollectionChanged(object sender, NotifyingCollectionChangedEventArgs<DashboardItem> e)
{
Dashboard dBoard = sender as Dashboard;
if (e.AddedItems.Count > 0)
{
if (e.AddedItems.Count == 1 && dBoard.Items.Count(i => i.Name == e.AddedItems[0].Name) > 1)
AddToLog("Duplicated", e.AddedItems);
else
AddToLog("Added", e.AddedItems);
}
if (e.RemovedItems.Count > 0)
{
AddToLog("Removed", e.RemovedItems);
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ItemCollectionChanged event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.