How to customize search keyword highlighting

In order to customize search keyword highlighting in WPF viewer, the current style should be overridden by the custom style.

To do this,

            1) Open the XAML page in designer mode

             2) Add the following namespace to the XAML page


1
xmlns:presentation="clr-namespace:PerpetuumSoft.Reporting.WPF.Presentation;assembly=PerpetuumSoft.Reporting.WPF" 

.           3) Add the following code to ‘Resources’ section and customize the keyword highlighting style as required:


 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
            <reports:ReportViewer.Resources>
                <Style TargetType="presentation:PagePresenter">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="presentation:PagePresenter">
                                <Grid FlowDirection="LeftToRight">
                                    <Border Background="White"  BorderBrush="Black" BorderThickness="1 1 0 1" Margin="0 0 -1 0">
                                        <Canvas x:Name="pageCanvas">
                                            <Rectangle x:Name="hightlight" Visibility="Collapsed" StrokeThickness="1" >
                                                <Rectangle.Stroke>
                                                    <SolidColorBrush Color="#FFFFCB5A"/>
                                                </Rectangle.Stroke>
                                                <Rectangle.Fill>
                                                    <SolidColorBrush Color="Red" Opacity="0.2"/>
                                                </Rectangle.Fill>
                                            </Rectangle>
                                        </Canvas>
                                    </Border>
                                    <Border Background="Transparent"  BorderBrush="Black" BorderThickness="0 0 1 0" Margin="0 0 -2 0" IsHitTestVisible="False"/>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </reports:ReportViewer.Resources> 

Add Feedback