WPF、C#:弹出窗口的多个声明创建问题
WPF,C#: Multiple declarations of popup creating problems
我有一个使用弹出窗口的 Prism WPF 应用程序。多个地方需要相同的功能,所以我像这样引用了我的弹出窗口。
<i:Interaction.Triggers>
<interactionRequest:InteractionRequestTrigger SourceObject="{Binding CreateCatalogsRequest, Mode=OneWay}">
<interactionRequest:PopupWindowAction>
<interactionRequest:PopupWindowAction.WindowContent>
<!-- Problem line below -->
<view:SomePopUpView />
</interactionRequest:PopupWindowAction.WindowContent>
</interactionRequest:PopupWindowAction>
</interactionRequest:InteractionRequestTrigger>
</i:Interaction.Triggers>
这段完全相同的代码片段目前出现在两个控件中。当我注释掉代码,或用标准组件 (Combobox) 替换 "SomePopupView" 时,我的应用程序可以正常工作。当我让它引用同一个组件 (SomePopupView) 两次时,我的应用程序会抱怨区域问题。
我不想重写或扩展或做任何架构巫术,但我如何在应用程序的不同部分获得相同的弹出功能?
非常感谢任何帮助
编辑 AnjumSKhan 提供的解决方案有效。我的解决方法如下
App.xaml
<Application.Resources>
<view:SomePopupView x:Key="SomePopupView" />
....
<Application.Resources>
带有重复弹出窗口的视图
<i:Interaction.Triggers>
<interactionRequest:InteractionRequestTrigger SourceObject="{Binding CreateRequestInteraction, Mode=OneWay}">
<interactionRequest:PopupWindowAction>
<interactionRequest:PopupWindowAction.WindowContent>
<ContentControl Content="{StaticResource SomePopupView}"></ContentControl>
</interactionRequest:PopupWindowAction.WindowContent>
</interactionRequest:PopupWindowAction>
</interactionRequest:InteractionRequestTrigger>
</i:Interaction.Triggers>
解决方案。
App.xaml
<Application.Resources>
<view:SomePopupView x:Key="SomePopupView" />
....
<Application.Resources>
带有重复弹出窗口的视图
<i:Interaction.Triggers>
<interactionRequest:InteractionRequestTrigger SourceObject="{Binding CreateRequestInteraction, Mode=OneWay}">
<interactionRequest:PopupWindowAction>
<interactionRequest:PopupWindowAction.WindowContent>
<ContentControl Content="{StaticResource SomePopupView}"></ContentControl>
</interactionRequest:PopupWindowAction.WindowContent>
</interactionRequest:PopupWindowAction>
</interactionRequest:InteractionRequestTrigger>
</i:Interaction.Triggers>
我有一个使用弹出窗口的 Prism WPF 应用程序。多个地方需要相同的功能,所以我像这样引用了我的弹出窗口。
<i:Interaction.Triggers>
<interactionRequest:InteractionRequestTrigger SourceObject="{Binding CreateCatalogsRequest, Mode=OneWay}">
<interactionRequest:PopupWindowAction>
<interactionRequest:PopupWindowAction.WindowContent>
<!-- Problem line below -->
<view:SomePopUpView />
</interactionRequest:PopupWindowAction.WindowContent>
</interactionRequest:PopupWindowAction>
</interactionRequest:InteractionRequestTrigger>
</i:Interaction.Triggers>
这段完全相同的代码片段目前出现在两个控件中。当我注释掉代码,或用标准组件 (Combobox) 替换 "SomePopupView" 时,我的应用程序可以正常工作。当我让它引用同一个组件 (SomePopupView) 两次时,我的应用程序会抱怨区域问题。
我不想重写或扩展或做任何架构巫术,但我如何在应用程序的不同部分获得相同的弹出功能?
非常感谢任何帮助
编辑 AnjumSKhan 提供的解决方案有效。我的解决方法如下
App.xaml
<Application.Resources>
<view:SomePopupView x:Key="SomePopupView" />
....
<Application.Resources>
带有重复弹出窗口的视图
<i:Interaction.Triggers>
<interactionRequest:InteractionRequestTrigger SourceObject="{Binding CreateRequestInteraction, Mode=OneWay}">
<interactionRequest:PopupWindowAction>
<interactionRequest:PopupWindowAction.WindowContent>
<ContentControl Content="{StaticResource SomePopupView}"></ContentControl>
</interactionRequest:PopupWindowAction.WindowContent>
</interactionRequest:PopupWindowAction>
</interactionRequest:InteractionRequestTrigger>
</i:Interaction.Triggers>
解决方案。
App.xaml
<Application.Resources>
<view:SomePopupView x:Key="SomePopupView" />
....
<Application.Resources>
带有重复弹出窗口的视图
<i:Interaction.Triggers>
<interactionRequest:InteractionRequestTrigger SourceObject="{Binding CreateRequestInteraction, Mode=OneWay}">
<interactionRequest:PopupWindowAction>
<interactionRequest:PopupWindowAction.WindowContent>
<ContentControl Content="{StaticResource SomePopupView}"></ContentControl>
</interactionRequest:PopupWindowAction.WindowContent>
</interactionRequest:PopupWindowAction>
</interactionRequest:InteractionRequestTrigger>
</i:Interaction.Triggers>