我正在尝试在其自己的模块中创建自定义弹出窗口,这会导致我出现以下情况(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 属性(通知和 FinishInteraction )在视图和视图上都为空模型。
这是设置这些属性的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
属性?
答案 0 :(得分:2)
你有两种选择;创建一个实现适当接口的自定义ContentControl。或者,创建并使用对话服务。我实际上建议使用对话服务,因为你想要一个更动态的弹出行为。 Plural服务涵盖PluralSight课程'Prism Problems&amp; amp;解决方案:显示多个壳。