![](/img/trans.png)
[英]Finding the Center of a Winforms Control hosted in a Wpf WindowsFormsHost
[英]Active Reports winforms viewer control hosted in WPF Window
當前沒有用於Active Reports 6的WPF查看器 。 我試圖使用主機控件在互操作主機中顯示查看器,但運氣不佳。 還有其他人嘗試成功嗎? 此時,我什至無法將包裝器Viewer控件作為自定義控件添加到項目工具箱中。 我希望避免重新創建輪子。
現有的ActiveReports Viewer在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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.