我想创建一个WPF窗口“ReportViewer”,然后打开一个我在Telerik report上创建的报表,而不将其包含到我的项目中,因为我希望用户可以编辑它们,或者如果他们愿意,可以自己添加新的报表(然后文件将位于特定的文件夹中)。
现在我无法打开Telerik报告,下面是我使用的代码:
public MainWindow()
{
InitializeComponent();
var report = new UriReportSource();
report.Uri = "Report1.trdx";
this.reportViewer1.ReportSource = report;
}
XAML公司
<Window x:Class="Test_Telerik.MainWindow"
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"
xmlns:local="clr-namespace:Test_Telerik"
mc:Ignorable="d"
xmlns:telerik="clr-namespace:Telerik.ReportViewer.Wpf;assembly=Telerik.ReportViewer.Wpf"
Title="MainWindow" Height="450" Width="800">
<Grid>
<telerik:ReportViewer Name="reportViewer1" />
</Grid>
</Window>
但我的窗户上什么也没有。
然后我还试图定义一个绝对Uri:
report.Uri = "D:\\Projects\\Test_Telerik\\Test_Telerik\\Report1.trdx";
编辑:答案标记为
Duplicate