This example demonstrates how to synchronize Master Filter and Drill-Down actions between different dashboards.
The main form contains the DashboardControl with a loaded sample dashboard. The Show Child Window button invokes another window containing the DashboardControl with a different dashboard.
Master Filtering and Drill-Down and
actions performed in the main window are applied to the child window.
To accomplish this, the child window subscribes to the following events of the main window's DashboardControl:
- DashboardControl.MasterFilterSet
- DashboardControl.MasterFilterCleared
- DashboardControl.DrillDownPerformed
- DashboardControl.DrillUpPerformed
When an event occurs, the following methods are used to apply filter values to the child window's DashboardViewer control or to perform the data drill-down or drill-up operations:
- DashboardControl.SetMasterFilter
- DashboardControl.SetRange
- DashboardControl.PerformDrillDown
- DashboardControl.PerformDrillUp
Files to Review
- ChildWindow.xaml / VB: ChildWindow.xaml
- ChildWindow.xaml.cs / ChildWindow.xaml.vb
- MainWindow.xaml / VB: MainWindow.xaml
- MainWindow.xaml.cs / MainWindow.xaml.vb
Documentation
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
XAML<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfDashboard_LinkedInteractivity"
xmlns:dxdash="http://schemas.devexpress.com/winfx/2008/xaml/dashboard" x:Class="WpfDashboard_LinkedInteractivity.ChildWindow"
mc:Ignorable="d"
Title="ChildWindow" Height="600" Width="800" Loaded="Window_Loaded">
<Grid>
<dxdash:DashboardControl x:Name="childDashboardControl" MinHeight="150"/>
</Grid>
</Window>
C#using DevExpress.DashboardCommon;
using DevExpress.DashboardCommon.ViewerData;
using DevExpress.DashboardWpf;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace WpfDashboard_LinkedInteractivity
{
/// <summary>
/// Interaction logic for ChildWindow.xaml
/// </summary>
public partial class ChildWindow : Window
{
private DashboardControl dControl;
public ChildWindow(DashboardControl dControl)
{
InitializeComponent();
this.dControl = dControl;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
childDashboardControl.LoadDashboard("Data\\DashboardChild.xml");
DashboardControl dParentControl = this.dControl;
dParentControl.MasterFilterSet += DControl_MasterFilterSet;
dParentControl.MasterFilterCleared += DControl_MasterFilterCleared;
dParentControl.DrillDownPerformed += DControl_DrillDownPerformed;
dParentControl.DrillUpPerformed += DControl_DrillUpPerformed;
}
bool HasDashboardItem(string itemName)
{
return childDashboardControl.Dashboard.Items.
Select(i => i.ComponentName).Contains(itemName);
}
private void DControl_MasterFilterSet(object sender, MasterFilterSetEventArgs e)
{
if (HasDashboardItem(e.DashboardItemName))
{
string itemName = e.DashboardItemName;
if (e.SelectedValues != null)
childDashboardControl.SetMasterFilter(itemName, e.SelectedValues);
if (e.SelectedRange != null)
childDashboardControl.SetRange(itemName, e.SelectedRange);
}
}
private void DControl_MasterFilterCleared(object sender, MasterFilterClearedEventArgs e)
{
if (HasDashboardItem(e.DashboardItemName))
{
string itemName = e.DashboardItemName;
if (childDashboardControl.CanClearMasterFilter(itemName))
childDashboardControl.ClearMasterFilter(itemName);
}
}
private void DControl_DrillDownPerformed(object sender, DrillActionEventArgs e)
{
if (HasDashboardItem(e.DashboardItemName))
{
string itemName = e.DashboardItemName;
DashboardDataRow row = e.Values[0];
object value = row[row.Length - 1];
IList<AxisPointTuple> tuple = childDashboardControl.GetAvailableDrillDownValues(itemName);
IEnumerable<object> availableValues = tuple.Select(t => t.GetAxisPoint().UniqueValue);
if (availableValues.Contains(value))
{
childDashboardControl.PerformDrillDown(e.DashboardItemName, value);
}
}
}
private void DControl_DrillUpPerformed(object sender, DrillActionEventArgs e)
{
if (HasDashboardItem(e.DashboardItemName))
{
string itemName = e.DashboardItemName;
int level = e.DrillDownLevel;
AxisPointTuple tuple = childDashboardControl.GetCurrentDrillDownValues(itemName);
if (tuple != null)
{
AxisPoint point = childDashboardControl.GetCurrentDrillDownValues(itemName).GetAxisPoint();
int l = 0;
while (point.Parent != null)
{
l++;
point = point.Parent;
}
if ((level + 1) == l && childDashboardControl.CanPerformDrillUp(itemName))
childDashboardControl.PerformDrillUp(itemName);
}
}
}
}
}
XAML<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfDashboard_LinkedInteractivity"
xmlns:dxdash="http://schemas.devexpress.com/winfx/2008/xaml/dashboard" x:Class="WpfDashboard_LinkedInteractivity.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="600" Width="800" Loaded="Window_Loaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Row="0" Click="Button_Click">Show Child Window</Button>
<dxdash:DashboardControl x:Name="mainDashboardControl" Grid.Row="1" MinHeight="150"/>
</Grid>
</Window>
C#using System.Windows;
namespace WpfDashboard_LinkedInteractivity
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
mainDashboardControl.LoadDashboard("Data\\Dashboard.xml");
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ChildWindow childWindow1 = new ChildWindow(mainDashboardControl);
childWindow1.Show();
}
}
}