Category / Section
How to Wrap BI PivotGridControl and PivotSchemaDesigner as Custom Control for LightSwitch
2 mins read
Steps to create a sample in Light Switch Application:
- Open the Visual Studio, Click File->New Project and Open Light Switch Application(Visual C#).
- Create a new table or attach the Data Source by right-clicking the Data Sources in Solution Explorer Window or Project-> Add Data Source in Menu Bar.
- Here we have attached a Data Source using Northwind Entities Data .
- For that Click on OData Service in Attach Data Source wizard and click Next.
- Specify the OData Service endpoint as “http://services.odata.org/Northwind/Northwind.svc/” and click next.
- Select the tables you want and click finish. (Here we have used Order_Details Table in our Sample).
- After attaching Data Source, Add Screen by right-clicking the Screens in Solution Explorer Window or Project-> Add Screen in Menu Bar.
- In the Add New Screen Window Select “Editable Grid Screen” as Screen Template and “NorthwindEntitiesData.Order_Details” as Screen Data.
- By Default the Screen is viewed in DataGrid View.
- To view the screen in Pivot Grid view, follow the steps below:
- Create a Silverlight Class Library by adding new project.
- Right Click the Class Library and add a new Silverlight User Control.
- In the User Control window add a PivotGrid control.
- Add the rows, columns, Calculation items in the Pivot Grid Control.(Note that the Field Mapping Name of rows, columns and calculation item should be occurred in Table)
- The Item Source property of the Pivot Grid Control can be binded by giving “itemSource=” {Binding Screen.Order_Details}” “.
- Add Pivot Schema Designer.
- Now add a Custom Control in Screen by Clicking Add-> New Custom control in designer page
- Add the User Control by clicking the Add Reference button in window and selecting your Silverlight class library in Projects.
- Build the solution and Run.
Figure: Custom Control displaying Pivot Grid only
Figure: Custom control displaying both pivot Grid and Schema Designer