Reputation: 1813
I have a problem with Prism / WPF custom interaction request popups. The popup renders correctly on first request, but each subsequent popup reuses the same view. This results in TextBlock
controls concatenating text, scroll bars not being visible, dynamic data in ItemsControl
items not being visible, the popup window having wrong size, etc. Is it possible to force creation of new popup window with each new interaction request or refresh all controls in the popup?
To show popup I am using standard code from PRISM documentation, for example the popup is instantiated as:
PopUpViewModel displayData = reportCreator.GetReport();
this.CustomConfirmationRequest.Raise(displayData, res => {
if (res.Confirmed)
{ ... }
});
where PopUpViewModel
inherits Confirmation, IInteractionRequestAware
XAML is:
<prism:InteractionRequestTrigger SourceObject="{Binding CustomConfirmationRequest, Mode=OneWay}">
<prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True" WindowStartupLocation="CenterScreen" >
<prism:PopupWindowAction.WindowContent>
<popups:SoPopUp/>
</prism:PopupWindowAction.WindowContent>
</prism:PopupWindowAction>
</prism:InteractionRequestTrigger>
Upvotes: 0
Views: 957
Reputation: 3147
Instead of
<prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True" WindowStartupLocation="CenterScreen">
<prism:PopupWindowAction.WindowContent>
<popups:SoPopUp/>
</prism:PopupWindowAction.WindowContent>
</prism:PopupWindowAction>
you may use
<prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True" WindowStartupLocation="CenterScreen" WindowContentType = "{x:Type popups:SoPopUp}"/>
When you specify WindowContent, the instance of SoPopUp is created once when this xaml is loaded. It is then reused every time the PopupWindowAction is triggered. If you specify WindowContentType, an instance of SoPopUp is created anew each time the PopupWindowAction is triggered. Note also that DI is used to instantiate SoPopUp so that the SoPopUp constructor may have arguments to be resolved by DI.
Upvotes: 5