显示自定义通知请求时出现错误“必须设置ServiceLocationProvider”

时间:2018-08-09 02:24:35

标签: wpf mvvm prism

我尝试在棱柱形自定义通知中显示一个reportviewer,该报告每次显示时都必须动态更改,这是到目前为止的代码,

XAML

<i:Interaction.Triggers>
    <prism:InteractionRequestTrigger
        SourceObject="{Binding ReportPopupRequest}">
        <prism:PopupWindowAction
            CenterOverAssociatedObject="True"
            IsModal="True">
            <prism:PopupWindowAction.WindowContent>
                <local:ReportView />
            </prism:PopupWindowAction.WindowContent>
        </prism:PopupWindowAction>
    </prism:InteractionRequestTrigger>
</i:Interaction.Triggers>

自定义Notification界面和类

public interface IReportNotification : INotification
{
    ReportParam ReportParam { get; set; }
}

public class ReportNotification : Notification, IReportNotification
{
    public ReportParam ReportParam { get; set; }
}

显示通知的ViewModel部分

// ...

public InteractionRequest<IReportNotification> ReportPopupRequest { get; set; }

private void Init()
{
    // ...
    ReportPopupRequest = new InteractionRequest<IReportNotification>();
    // ...
}

private void ShowReportViewer(ReportParam param)
{
    ReportPopupRequest.Raise(new ReportNotification
    {
        Title = "Report Viewer",
        ReportParam = param
    }, r => r.Title = "Good to go");
}

使用上面的代码,我显示包含reportviewer的弹出通知,但是,这是第一次,reportviewer显示传递给自定义Notification的正确数据,但是如果我尝试显示另一个具有不同参数的报告,弹出窗口仍会显示相同的报告,

实际上,我尝试在此线程PRISM WPF Custom interaction request - dynamic view controls don't show correctly中实现答案,但在此部分出现错误“必须设置ServiceLocationProvider”

ReportPopupRequest.Raise(new ReportNotification
{
    Title = "Report Viewer",
    ReportParam = param
}, r => r.Title = "Good to go");

0 个答案:

没有答案