[]
Let us see how we can customize different elements of WPF Viewer.
The ActiveReports WPF Viewer is a customizable control. You can easily change the look of the WPF Viewer and its elements, such as the error panel, search panel, sidebar and toolbar by modifying properties in the default WPF Viewer template (DefaultWPFiewerTemplates.xaml).
Once you copy the template, you can modify the default style and apply it to your viewer by creating the desired style and setting its Template property.
Note that while modifying the template, do not remove the required template parts. The required parts are usually marked with the prefix "PART_".
The template allows you to customize the appearance of viewer and take advantage of XAML-based styling.
<Window.Resources>
<ResourceDictionary Source="DefaultWPFViewerTemplates.xaml" />
</Window.Resources>
In Solution Explorer, select the YourProjectName node.
On the Visual Studio Project menu, select Add New Item.
In the Add New Item dialog that appears, select Class, rename it to MyCommand and click Add.
In the MyCommand.cs/vb that opens, add the following code to implement a command.
Implements ICommand
Public Function CanExecute(ByVal parameter As Object) As Boolean Implements System.Windows.Input.ICommand.CanExecute
Return True
End Function
Public Event CanExecuteChanged(ByVal sender As Object, ByVal e As System.EventArgs) Implements System.Windows.Input.ICommand.CanExecuteChanged
Public Sub Execute(ByVal parameter As Object) Implements System.Windows.Input.ICommand.Execute
MessageBox.Show("MESCIUS is the world's largest component vendor.", "About Us", MessageBoxButton.OK)
End Sub
using System.Windows.Input;
using System.Windows;
public class MyCommand : ICommand
{
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
MessageBox.Show("MESCIUS is the world's largest component vendor.", "About Us", MessageBoxButton.OK);
}
public event EventHandler CanExecuteChanged;
}
In Solution Explorer, double-click DefaultWpfViewerTemplates.xaml.
In the file that opens, add the following 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.
<Button Command="{StaticResource MyCommand}" Content="About Us" />
Press F5 to see the new customized button About Us in the Viewer toolbar.
<Button Command=... Visibility="Collapsed">