Skip to main content

DashboardControl.SetDashboardState(DashboardState) Method

Applies the dashboard state to the loaded dashboard.

Namespace: DevExpress.DashboardWpf

Assembly: DevExpress.Dashboard.v24.1.Wpf.dll

NuGet Package: DevExpress.Wpf.Dashboard

Declaration

public void SetDashboardState(
    DashboardState state
)

Parameters

Name Type Description
state DashboardState

A DashboardState object.

Remarks

The following code snippet sets the created dashboard state:

using DevExpress.DashboardCommon;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Xml.Linq;

namespace WpfDashboard_DashboardState
{
    public partial class MainWindow : Window
    {
        public static readonly string PropertyName = "DashboardState";

        public MainWindow()
        {
            InitializeComponent();

        }

        public DashboardState CreateDashboardState() {
            DashboardState state = new DashboardState();
            // Set a range for a Range Filter.
            state.Items.Add(new DashboardItemState("rangeFilterDashboardItem1") {
                RangeFilterState = new RangeFilterState(new RangeFilterSelection(new DateTime(2015, 1, 1), new DateTime(2017, 1, 1)))
            });
            // Specify master filter and drill-down values.
            state.Items.Add(new DashboardItemState("gridDashboardItem1") {
                MasterFilterValues = new List<object[]>() { new object[] { "Gravad lax" }, new object[] { "Ikura" } },
                DrillDownValues = new List<object>() { "Seafood" }
            });
            // Set a dashboard item layer.
            state.Items.Add(new DashboardItemState("treemapDashboardItem1") {
                SelectedLayerIndex = 1
            });
            // Specify a default tab page.
            state.Items.Add(new DashboardItemState("tabContainerDashboardItem1") {
                TabPageName = "dashboardTabPage2"
            });
            // Define a dashboard parameter value.
            state.Parameters.Add(new DashboardParameterState() {
                Name = "ParameterCountry",
                Value = "UK",
                Type = typeof(string)
            });
            return state;
        }

        private void dashboardControl_DashboardLoaded(object sender, DevExpress.DashboardWpf.DashboardLoadedEventArgs e) {
            var state = CreateDashboardState();
            dashboardControl.SetDashboardState(state);
        }
    }
}

To learn more about a dashboard state, refer to the Manage Dashboard State document.

See Also