简体   繁体   English

WPF窗口中托管的Active Reports Winforms查看器控件

[英]Active Reports winforms viewer control hosted in WPF Window

There is currently not an available WPF viewer for Active Reports 6 . 当前没有用于Active Reports 6的WPF查看器 I was attempting to use a host control to display the viewer in a interop host but I'm not having much luck. 我试图使用主机控件在互操作主机中显示查看器,但运气不佳。 Has anyone else attempted this successfully? 还有其他人尝试成功吗? I can't even get the wrapper Viewer control to add to the project toolbox as a custom control at this point. 此时,我什至无法将包装器Viewer控件作为自定义控件添加到项目工具箱中。 I'm hoping to avoid recreating the wheel. 我希望避免重新创建轮子。

The existing ActiveReports Viewer works fine in WPF. 现有的ActiveReports Viewer在WPF中可以正常工作。 You can use the below XAML to host it in 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>

The following code in the code-behind of the XAML file will connect a report to the viewer in the XAML above and run it: 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();
    }
}

I'm using the currently available version of ActiveReports 6 to test this. 我正在使用ActiveReports 6当前可用版本对此进行测试。

Hope this helps! 希望这可以帮助!

Scott Willeke
GrapeCity

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM