Example T830576
Visible to All Users

Dashboard for WPF - How to Synchronize Master Filter and Drill Down Actions Between Dashboards

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:

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:

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

WpfDashboard_LinkedInteractivity/ChildWindow.xaml
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>
WpfDashboard_LinkedInteractivity/ChildWindow.xaml.cs(vb)
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); } } } } }
WpfDashboard_LinkedInteractivity/MainWindow.xaml
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>
WpfDashboard_LinkedInteractivity/MainWindow.xaml.cs(vb)
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(); } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.