ReportViewer不显示报告 - URL问题?

时间:2014-09-03 18:50:36

标签: c# xaml mvvm

我有这个:

<Window>
<ContentPresenter Content="{Binding Viewer}" />
</Window>
internal class MainViewModel : ObservableObject{

        private WindowsFormsHost _viewer;
        public WindowsFormsHost Viewer
        {
            get { return _viewer; }
            set { Set(() => Viewer, ref _viewer, value); }
        }

        public MainViewModel()
        {
            _viewer = new WindowsFormsHost();
            var reportViewer = new ReportViewer();
            reportViewer.ProcessingMode = ProcessingMode.Remote;
            reportViewer.ServerReport.ReportServerUrl = new Uri("http://someservername/Reports/Pages/Folder.aspx");                    
            reportViewer.ServerReport.ReportPath = "ItemPath=/somefolder1/somefolder2/ReportX";
            Viewer.Child = reportViewer;
        }
    }

我可以在窗口顶部看到禁用的报告服务工具栏,但没有报告。我一直在为ReportPath和ReportServerUrl分配各种字符串,但什么都没有。这是一个URL问题吗?当然,如果我把它放到浏览器中,URL就可以工作了。感谢。

2 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。我不确定这对你有用,但就我而言, 代码PFObject *gameScore = [PFObject objectWithClassName:@"GameScore"]; gameScore[@"score"] = @1337; gameScore[@"playerName"] = @"Sean Plott"; gameScore[@"cheatMode"] = @NO; [gameScore saveEventually]; 中的行必须移至xaml,例如

Var reportViewer = new ReportViewer

现在,为什么它表现得像我真的不知道。

答案 1 :(得分:0)

我知道这是一个非常古老的问题,但更多的是寻找未来发现相同错误的人,我只是找到并解决了同样的错误......

您需要引入reportViewer类的函数调用RefreshReport。像这样:

    public MainViewModel()
    {
        _viewer = new WindowsFormsHost();
        var reportViewer = new ReportViewer();
        reportViewer.ProcessingMode = ProcessingMode.Remote;
        reportViewer.ServerReport.ReportServerUrl = new Uri("http://someservername/Reports/Pages/Folder.aspx");                    
        reportViewer.ServerReport.ReportPath = "ItemPath=/somefolder1/somefolder2/ReportX";
        reportviewer.RefreshReport();
        Viewer.Child = reportViewer;
    }