主动报告的WinForms观众控制在托管WPF窗口
-
26-09-2019 - |
题
目前不主动报告6 可用WPF查看器。我试图用一台主机控制显示在互操作主机的观众,但我并没有多少运气。有没有其他人尝试成功吗?我甚至无法包装查看器控件添加到项目工具箱如在这一点上的自定义控件。我希望避免重新创建轮。
解决方案
在现有的ActiveReports查看器工作在WPF细。您可以在WPF使用下面的XAML将主机吧:
<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
不隶属于 StackOverflow