【发布时间】:2015-10-19 20:20:00
【问题描述】:
我正在尝试在它自己的模块中创建一个自定义弹出窗口,这导致我出现以下情况(ContentControl 内 PopupWindowAction):
<i:Interaction.Triggers>
<prism:InteractionRequestTrigger SourceObject="{Binding Path=MyRequest, Mode=OneWay}">
<prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
<prism:PopupWindowAction.WindowContent>
<ContentControl prism:RegionManager.RegionName="{x:Static inf:RegionNames.MyRegion}"/>
</prism:PopupWindowAction.WindowContent>
</prism:PopupWindowAction>
</prism:InteractionRequestTrigger>
</i:Interaction.Triggers>
视图很好地加载到弹出窗口中,但 IInteractionRequestAware 属性(Notification 和 FinishInteraction)在 View 和 View 上都是 null型号。
这是设置这些属性的 Prism 源代码:
/// <summary>
/// Checks if the WindowContent or its DataContext implements <see cref="IInteractionRequestAware"/>.
/// If so, it sets the corresponding value.
/// Also, if WindowContent does not have a RegionManager attached, it creates a new scoped RegionManager for it.
/// </summary>
/// <param name="notification">The notification to be set as a DataContext in the HostWindow.</param>
/// <param name="wrapperWindow">The HostWindow</param>
protected virtual void PrepareContentForWindow(INotification notification, Window wrapperWindow)
{
if (this.WindowContent == null)
{
return;
}
// We set the WindowContent as the content of the window.
wrapperWindow.Content = this.WindowContent;
Action<IInteractionRequestAware> setNotificationAndClose = (iira) =>
{
iira.Notification = notification;
iira.FinishInteraction = () => wrapperWindow.Close();
};
MvvmHelpers.ViewAndViewModelAction(this.WindowContent, setNotificationAndClose);
}
这是否意味着正在检查 ContentControl 对象以查看它是否实现了 IInteractionRequestAware 而不是我的视图或视图模型?
是否可以使用区域管理器来指定一个自定义弹出视图,其中所有注入都发生了,并且仍然设置了 IInteractionRequestAware 属性?
【问题讨论】: