Back to Devexpress

DashboardControl.DashboardStateChanged Event

dashboard-devexpress-dot-dashboardwpf-dot-dashboardcontrol-ba2fd780.md

latest7.5 KB
Original Source

DashboardControl.DashboardStateChanged Event

Occurs after the current dashboard state in the DashboardControl is changed.

Namespace : DevExpress.DashboardWpf

Assembly : DevExpress.Dashboard.v25.2.Wpf.dll

NuGet Package : DevExpress.Wpf.Dashboard

Declaration

csharp
public event DashboardStateChangedWpfEventHandler DashboardStateChanged
vb
Public Event DashboardStateChanged As DashboardStateChangedWpfEventHandler

Event Data

The DashboardStateChanged event's data class is DashboardStateChangedWpfEventArgs. The following properties provide information specific to this event:

PropertyDescription
DashboardA dashboard whose state can be initialized. Inherited from SetInitialDashboardStateBaseEventArgs.
DashboardStateGets the current state of the dashboard.
InitialStateGets or sets the dashboard initial state. Inherited from SetInitialDashboardStateBaseEventArgs.

Remarks

A dashboard state contains the selected master filter values, current drill-down levels, Range Filter and Date Filter settings, dashboard item layers and current parameter values. Use the DashboardStateChanged event to get the actual dashboard state - the latest interaction changes a user made to a dashboard. The DashboardState property provides access to the states of individual dashboard items displayed in the dashboard.

You can use the DashboardControl.SetInitialDashboardState event to apply the state when a dashboard is loaded.

For more information about a dashboard state, see Manage Dashboard State.

Example

This example demonstrates how to use the DashboardStateChanged event to display the result of user interactions. The DashboardState.Items property accesses the states of individual dashboard items. The TextEdit control displays the name of the Item and its filter values, current drill-down levels, and range-filter selections each time the dashboard state changes.

View Example: How to Use the DashboardStateChanged Event to Display User Interactions

csharp
using DevExpress.DashboardCommon;
using DevExpress.DashboardWpf;
using System;
using System.Linq;
using System.Windows;
// ...
 private void DashboardControl_DashboardStateChanged(object sender, DashboardStateChangedWpfEventArgs e) {
    var newState = e.DashboardState;
    var message = string.Empty;
    foreach(DashboardItemState itemState in newState.Items) {
        var item = dashboardControl1.Dashboard.Items[itemState.ItemName];
        message += item.Name;
        if( itemState.DrillDownValues.Count != 0) {
            message += "\n" + "Filter Drill-Down:" + " " + string.Join("," , itemState.DrillDownValues);
        }
        if(itemState.MasterFilterValues.Count != 0) {
            message += "\n" + "Master Filter:" + " " + string.Join(" | ", itemState.MasterFilterValues.Select(v=> string.Join(",",v))); 
        }
        if (itemState.RangeFilterState.Selection.Minimum !=null || itemState.RangeFilterState.Selection.Maximum != null) {
            message += "\n" + "Range Filter:" + " " + ((DateTime)itemState.RangeFilterState.Selection.Minimum).ToString("y") + "-" + ((DateTime)itemState.RangeFilterState.Selection.Maximum).ToString("y");
        }
        message += Environment.NewLine;
        message += "\n";
    }
          TextEdit.Text = message;  
}
vb
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWpf
Imports System
Imports System.Linq
Imports System.Windows
' ...
 Private Sub DashboardControl_DashboardStateChanged(ByVal sender As Object, ByVal e As DashboardStateChangedWpfEventArgs)
    Dim newState = e.DashboardState
    Dim message = String.Empty
    For Each itemState As DashboardItemState In newState.Items
        Dim item = dashboardControl1.Dashboard.Items(itemState.ItemName)
        message += item.Name
        If itemState.DrillDownValues.Count <> 0 Then
            message += Constants.vbLf & "Filter Drill-Down:" & " " & String.Join(",", itemState.DrillDownValues)
        End If
        If itemState.MasterFilterValues.Count <> 0 Then
            message += Constants.vbLf & "Master Filter:" & " " & String.Join(" | ", itemState.MasterFilterValues.Select(Function(v) String.Join(",",v)))
        End If
        If itemState.RangeFilterState.Selection.Minimum IsNot Nothing OrElse itemState.RangeFilterState.Selection.Maximum IsNot Nothing Then
            message += Constants.vbLf & "Range Filter:" & " " & (CDate(itemState.RangeFilterState.Selection.Minimum)).ToString("y") & "-" & (CDate(itemState.RangeFilterState.Selection.Maximum)).ToString("y")
        End If
        message += Environment.NewLine
        message += Constants.vbLf
    Next itemState
          TextEdit.Text = message
 End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DashboardStateChanged 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.

wpf-dashboard-viewer-DashboardStateChanged-event/CS/WPF-DashboardStateChanged-Event/MainWindow.xaml#L16

xml
DashboardSource="../../Dashboards/dashboard1.xml"
                         DashboardStateChanged="DashboardControl_DashboardStateChanged" BorderThickness="3" />
<dxe:TextEdit Grid.Column="1" x:Name="TextEdit" VerticalContentAlignment="Top" />

See Also

SetInitialDashboardState

Manage Dashboard State in the WPF Viewer Control

DashboardControl Class

DashboardControl Members

DevExpress.DashboardWpf Namespace