Log in to like this post! How to Embed Analytics into Your WPF Project Lucia Rodriguez / Wednesday, February 28, 2018 In an age where users are looking for a high-value application with everything inside it or one to rule them all, it is becoming increasingly important for developers to keep their users interested. This is even truer for corporate users, who are meant to stay within the available company-approved options. ReportPlus rises to the challenge, providing the ability to embed unlimited custom data visualizations into any application. Learn how to use the ReportPlus SDK to embed analytics, cut development time, and give customers or users the ability to access their data in real-time and in context. A quick introduction to the ReportPlus SDK The ReportPlus SDK allows users to embed ReportPlus dashboards (.rplus files) in their own applications, providing organizations with analytical tools and IT providers with a wide range of highly customizable embedded analytic tools and data visualizations. As of ReportPlus Desktop 1.3, the SDK is provided to users in the application installer's ReportPlus Embedded option. You can download it through this link. Using the ReportPlus SDK to Embed your Dashboards You can find the complete, step-by-step, guide on how to embed ReportPlus dashboards in the ReportPlus Help Topics. In the steps below, you will see how to create your own WPF project and embed a ReportPlus dashboard in an easy set of steps. Create a new WPF Application Project Note: Take into account that your Windows project needs to target .NET version 4.6 or higher because the ReportPlus.SDK libraries are built against .NET 4.6. Add your ReportPlus.dll files and Install theReportPlusSDK for WPF Packages The easiest way to get all the required assemblies referenced by the project is to install the ReportPlus SDK NuGet package. Find the ReportPlus Desktop SDK for WPF package and install it in your newly created WPF application. This might take a while, but you can monitor the Visual Studio status bar as it will show which NuGet packages are being installed. If you cannot find the ReportPlus package, you can add it manually through the VS NuGet Package manager: At this point, you should be all set up in terms of assembly references. You will now begin to build your application and link ReportPlus to it. Bring the ReportPlusViewer Control in. This control is responsible for displaying and presenting the dashboards. In order to integrate it: a. In the MainWindow.xaml file, add a namespace using xmlns:rplus=“http://schemas.infragistics.co/reportplus/ReportPlusDesktop”. b. Add the ReportPlusViewer control into the empty generated Grid in the MainWindow.xaml using <rplus:ReportPlusViewer Dashboard="{Binding Dashboard}”/>. Right now, there is nothing around in the DataContext named “Dashboard”, but we will take a look at that soon. Build and Run your Project Let’s now run your project. All it will show is just a blue labeled trial watermark that gets displayed at the bottom left corner. That is only if you have installed the trial version of the SDK. Feed a Dashboard to your ReportPlusView control So far, so good. Now, when we have the ReportPlusViewer control ready and into the visual tree, it will make sense to feed a dashboard to it so it can really show its power. To do so, you will need a dashboard first. In order to get one: a. Launch the ReportPlus Desktop application and log in. If you need help creating an account or logging in, you can refer to this help topic. b. Open the Samples folder. c. Open the Email Efforts dashboard. d. Export your Dashboard. At the top right corner, you should see an “Export” button; select the “Export File” option. The application will ask you whether you want the local data source; make sure you do include it to make the dashboard fully usable. e. Create a folder on your desktop named “Dashboards” and save the Email Efforts rplus file dashboard there. Add a ViewModel to your Project You’re almost there! You have your view and your Email Efforts dashboard. You will need to add a ViewModel to your project, which will glue those two together. Add a MainViewModel.cs class file to your project and implement INotifyPropertyChanged in it as you see fit. After the ViewModel is done, it makes sense to add a Dashboard property which the view will already be looking for. Here is how the ViewModel should be looking like by now: public class MainViewModel : INotifyPropertyChanged{ private Dashboard _dashboard; public Dashboard Dashboard { get { return _dashboard; } set { If (_dashboard != value) { _dashboard = value; RaisePropertyChanged("Dashboard"); } } } protected void RaisePropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public event PropertyChangedEventHandler PropertyChanged; Load the Dashboard We have the view, the infrastructure and the dashboard ready. What’s left is to load the rplus file stream and then load the Dashboard out of it. Here’s how to get this done – add a LoadDashboard method to your ViewModel: private void LoadDashboard() { var pathToTheDashboard = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), @"Dashboards\Email Efforts.rplus"); var fileStream = System.IO.File.Open(pathToTheDashboard, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite); Dashboard = Dashboard.Load(fileStream); } Don’t hit F5 just yet…Make sure you load the dashboard If you try to load your dashboard at this point, you will only see the white screen and the watermark you had seen during step 4. At this point, it is crucial that you actually call the loading routine to get the dashboard loaded. You can do this by adding the simplest constructor to your ViewModel, which will allow you to cross the finish line. public MainViewModel() { LoadDashboard(); } And that’s it! That’s how easy it is to embed a dashboard into your WPF project. To view the working example, download the ReportPlus Desktop application (if you already have an Infragistics account, you can use this link instead) and enjoy the ReportPlus Embedded experience. To learn more about ReportPlus Embedded, also check out our past blogs here.