0

Active Reports 6当前没有可用的 WPF 查看器。我试图使用主机控件在互操作主机中显示查看器,但我运气不佳。有没有其他人成功地尝试过这个?此时,我什至无法将包装查看器控件作为自定义控件添加到项目工具箱中。我希望避免重新创建轮子。

4

1 回答 1

2

现有的 ActiveReports 查看器在 WPF 中运行良好。您可以使用以下 XAML 在 WPF 中托管它:

<Window x:Class="ARViewerHostedInWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:arv="clr-namespace:DataDynamics.ActiveReports.Viewer;assembly=ActiveReports.Viewer6"  
        Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
    <Grid>
        <WindowsFormsHost Name="windowsFormsHost1">
            <arv:Viewer x:Name="ARViewer" Dock="Fill" />
        </WindowsFormsHost>
    </Grid>
</Window>

XAML 文件代码隐藏中的以下代码将报表连接到上述 XAML 中的查看器并运行它:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        NewActiveReport1 rpt = new NewActiveReport1();
        this.ARViewer.Document = rpt.Document;
        rpt.Run();
    }
}

我正在使用当前可用的 ActiveReports 6 版本进行测试。

希望这可以帮助!

Scott Willeke
GrapeCity
于 2010-07-27T18:32:22.967 回答