Update
What made me answer another question, because it is the inability to use the accepted answer to my project that uses Prism 6 ,
but after he placed the original answer (see. Below) and discussed it in I found that the main problem was in the following: Prism 6 changed the namespaces of some classes, all the classes that were used in the accepted answer still exist in Prism 6 , but in other dlls and namespaces
So, if you use Prism 6 , you can apply the accepted answer with these changes
replace these names first.
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:pi="clr-namespace:Microsoft.Practices.Prism.Interactivity;assembly=Microsoft.Practices.Prism.Interactivity"
xmlns:pit="clr-namespace:Microsoft.Practices.Prism.Interactivity.InteractionRequest;assembly=Microsoft.Practices.Prism.Interactivity"
with the following namespaces
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:prism="http://prismlibrary.com/"
second upgrade xaml as follows
<Button Content="Options" Command="{Binding OpenConnectionOptionsCommand}">
<i:Interaction.Triggers>
<prism:InteractionRequestTrigger SourceObject="{Binding OptionSettingConfirmationRequest, Mode=OneWay}" >
<prism:PopupWindowAction>
<prism:PopupWindowAction.WindowContent>
<views:CustomPopupView />
</prism:PopupWindowAction.WindowContent>
</prism:PopupWindowAction>
</prism:InteractionRequestTrigger>
</i:Interaction.Triggers>
</Button>
1
, , ( <views:CustomPopupWindow>), .
2
, Prism 6. ( ) dll, , Prism 6.
3
, dll Prism.Wpf, Nuget.
</" >
Prism 5, , Prism 6.
, , ( ), .
.
ViewModel
public class ViewModel : BindableBase
{
public ViewModel()
{
_showWindowCommand = new DelegateCommand(ShowWindow);
_interactionRequest = new InteractionRequest<Confirmation>();
}
private readonly DelegateCommand _showWindowCommand;
private InteractionRequest<Confirmation> _interactionRequest;
public ICommand ShowWindowCommand
{
get { return _showWindowCommand; }
}
public IInteractionRequest InteractionRequest
{
get { return _interactionRequest; }
}
private void ShowWindow()
{
_interactionRequest.Raise(
new Confirmation(),
OnWindowClosed);
}
private void OnWindowClosed(Confirmation confirmation)
{
if (confirmation.Confirmed)
{
}
else
{
}
}
}
XAML
<Button Command="{Binding ShowWindowCommand}" Content="Show Window" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Raised" SourceObject="{Binding InteractionRequest}">
<i:EventTrigger.Actions>
<local:ShowWindowAction></local:ShowWindowAction>
</i:EventTrigger.Actions>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:local="clr-namespace:The namespace which contains the ShowWindowAction">
ActionTrigger
using System;
using Prism.Interactivity.InteractionRequest;
using System.Windows.Interactivity;
using System.Windows;
public class ShowWindowAction : TriggerAction<FrameworkElement>
{
protected override void Invoke(object parameter)
{
InteractionRequestedEventArgs args = parameter as InteractionRequestedEventArgs;
if (args != null)
{
Confirmation confirmation = args.Context as Confirmation;
if (confirmation != null)
{
ParametersWindow window = new ParametersWindow();
EventHandler closeHandler = null;
closeHandler = (sender, e) =>
{
window.Closed -= closeHandler;
args.Callback();
};
window.Closed += closeHandler;
window.Show();
}
}
}
}
Prism.Core Prism.Wpf dlls ( ), .ShowWindow, Invoke ShowWindowAction, .OnWindowClosed, ShowWindowAction, , .