Forgot password?

Question: How to use FastReport.Net controls in WPF application?

Answer:

You should use WindowsFormsHost control for it:

0) Add reference on FastReport.dll;

1) Add attribute into Window(Page) tag: xmlns:fr="clr-namespace:FastReport.Preview;assembly=FastReport" if you want to use PreviewControl, xmlns:fr1="clr-namespace:FastReport.Design;assembly=FastReport" - if DesignerControl;

2) Add WindowsFormsHost tag into your XAML markup:

1
2
3
<WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.ColumnSpan="3">
 
</WindowsFormsHost>

 3) Add child into WindowsFormsHost: <fr:PreviewControl></fr:PreviewControl> or <fr1:Designer></fr1:Designer>.

Full markup should look like this snippet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<Window
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 x:Class="WpfApplication1.MainWindow"
 Title="MainWindow" Height="375.977" Width="939.258"
 xmlns:fr="clr-namespace:FastReport.Preview;assembly=FastReport">
 <Grid>
 <Grid.ColumnDefinitions>
 <ColumnDefinition Width="*"/>
 <ColumnDefinition Width="*"/>
 <ColumnDefinition Width="*"/>
 </Grid.ColumnDefinitions>
 <WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.ColumnSpan="3">
 <fr:PreviewControl></fr:PreviewControl>
 </WindowsFormsHost>
 </Grid>
</Window>