How to Bind a WPF Dashboard to an Object Data Source (List<Data>)

To learn how to bind a dashboard to the Object data source using the Visual Studio Designer, see the Providing Data topic.

This example demonstrates how to bind a dashboard to a System.Collections.Generic.List<T> object.

In this example, a dashboard is created in code at runtime and assigned to the DashboardControl.DashboardSource property within the Window_Loaded event handler. The created dashboard adds the DashboardObjectDataSource object to its DataSources collection and uses it as the data source for dashboard items.

Data for the DashboardObjectDataSource data source is supplied within the AsyncDataLoading event to the e.Data property. The DataSources collection may contain several data sources. The correct data source is determined by its name, which is assigned in the DashboardObjectDataSource constructor.

private void dashboardControl_AsyncDataLoading(object sender, DataLoadingEventArgs e)
{
    if (e.DataSourceName == "MyDataSource")
        e.Data = Data.CreateData();
}

The ReloadData() method is called to refresh the data.

Before loading an object data source, a warning message is displayed. This dialog allows end-users to select whether to trust the object data sources available in the application, as described in the Security Considerations document. Set the DashboardControl.ObjectDataSourceLoadingBehavior property to LoadAsIs to suppress the warning.

Note

The complete sample project How to Bind a WPF Dashboard to an Object Data Source is available in the DevExpress Examples repository.