The ActiveReports Silverlight Viewer is a customizable control. You can easily change the look of the Silverlight Viewer and such its elements as the error panel, search panel, sidebar and toolbar by modifying properties in the default Silverlight Viewer template (DefaultSLViewerTemplates.xaml).
To add the customization template to the Silverlight project
- Open your Silverlight project or create a new Silverlight project as described in Silverlight Viewer (Pro Edition).
- In Solution Explorer, select the YourProject directory.
- On the Visual Studio Project menu, click Add Existing item.
- In the dialog that appears, locate and select DefaultSLViewerTemplates.xaml and click OK. You can find DefaultSLViewerTemplates.xaml in the C:\Program Files\Grapecity\ActiveReports6\Deployment\Silverlight\Templates folder (on a 64-bit Windows operating system, this file is located in C:\Program Files (x86)\GrapeCity\ActiveReports 6\Deployment\Silverlight\Templates).
- On MainPage.xaml, add the following code to the <UserControl> section:
Paste to the UserControl section on Design view of MainPage.xaml |
Copy Code |
<UserControl.Resources>
<ResourceDictionary Source="DefaultSLViewerTemplates.xaml" />
</UserControl.Resources>
|
To customize the Silverlight Viewer sidebar
- In Solution Explorer, double-click DefaultSLViewerTemplates.xaml.
- In the file that opens, search for "sidebar implementation".
- In the Header property of <sdk:TabItem>, type "Sidebar".
- Open MainPage.xaml to see the Sidebar caption in the TOC view of the Silverlight Viewer.
To customize the Silverlight Viewer search panel
- In Solution Explorer, double-click DefaultSLViewerTemplates.xaml.
- In the file that opens, search for "searchpanel".
- Change the Color properties in the ControlTemplate section for View:SearchPanel.
- Press F5 to see the customized search panel.
To add a customized button to the Silverlight Viewer toolbar
- In Solution Explorer, select the YourProjectName directory.
- On the Visual Studio Project menu, select Add Class.
- In the Add New Item dialog that appears, select Class, rename it to MyCommand and click Add.
- In the MyCommand.cs that opens, add the following code to implement a command:
C# code. Add to AboutUsCommand.cs |
Copy Code |
public class MyCommand : ICommand
{
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
MessageBox.Show("GrapeCity is the world's largest component vendor.", "About Us", MessageBoxButton.OK);
}
public event EventHandler CanExecuteChanged;
}
|
- In the Solution Explorer, select the YourProjectName directory.
- On the Visual Studio Project menu, select Add Existing Item.
- In the Add Existing Item that opens, select the DefaultSLViewerTemplates.xaml and click Add.
- In the dialog that appears, locate and select DefaultSLViewerTemplates.xaml and click OK. You can find DefaultSLViewerTemplates.xaml in the C:\Program Files\Grapecity\ActiveReports6\Deployment\Silverlight\Templates folder (on a 64-bit Windows operating system, this file is located in C:\Program Files (x86)\GrapeCity\ActiveReports 6\Deployment\Silverlight\Templates).
- On MainPage.xaml, add the following code to the <UserControl> section:
Paste to the UserControl section on Design view of MainPage.xaml |
Copy Code |
<UserControl.Resources>
<ResourceDictionary Source="DefaultSLViewerTemplates.xaml" />
</UserControl.Resources>
|
- In Solution Explorer, double-click DefaultSLViewerTemplates.xaml.
- In the file that opens, add the following code.
XML code. Add to DefaultSLViewerTemplates.xaml |
Copy Code |
<ResourceDictionary>
...
xmlns:YourProjectName="clr-namespace:YourProjectName">
<YourProjectName:MyCommand x:Key="MyCommand" />
...
</ResourceDictionary>
|
- In the same file, add the following code to add a button.
XML code. Add to DefaultSLViewerTemplates.xaml inside the Grid tags |
Copy Code |
<Button Command="{StaticResource MyCommand}" Content="About Us" /> |
|
Note: ActiveReports 6 includes several predefined themes that you can find in the C:\Program Files\GrapeCity\ActiveReports 6\Deployment\Silverlight\Templates folder.
On a 64-bit Windows operating system, you can find the predefined themes in the C:\Program Files (x86)\GrapeCity\ActiveReports 6\Deployment\Silverlight\Templates folder. |
See Also
Getting Started
Walkthroughs