Closed harpagornis closed 8 years ago
EDIT, the popupwindow name is Confirm1View.xaml, the same as the triggeraction.
I am not familiar with MahApps, but why don't you just override CreateWindow and return your new MahApps window instance? PrepareContentForWindow doesn't return anything, so I'm not sure what you mean by that.
O.K. I will try it. Thank you.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I am using Mahapps to create a custom confirmation popup, ie. OK, Cancel. It seems to work, but only if I click the OK button twice. Oddly, when I step through in debugger, it only takes one click of the OK button to close the popup.
The view.xaml trigger:
<ie:Interaction.Triggers>
<interactionRequest:InteractionRequestTrigger SourceObject="{Binding ConfirmationRequest, Mode=OneWay}">
<controls:PopupWindowAction1 >
<controls:PopupWindowAction1.WindowContent>
<controlviews:Confirm1View/>
</controls:PopupWindowAction1.WindowContent>
</controls:PopupWindowAction1>
</interactionRequest:InteractionRequestTrigger>
</ie:Interaction.Triggers>
Here is the viewmodel that raises the confirmation request. The callback is working and gets the confirmed = true.
private void RaiseConfirmSave()
{
ConfirmationRequest.Raise(new Confirmation()
{ Title = "Confirm Changes", Content = "Save Changes to Record?"},
returned =>{if (!returned.Confirmed) { return;}
.... process confirmed
This is PopupWindowAction1: (I commented out the line, preparewindowcontent, because, with it in, the wrapperwindow was never returned).
class PopupWindowAction1 : PopupWindowAction, IInteractionRequestAware
{protected override Window GetWindow(INotification notification)
{MetroWindow wrapperWindow;
if (WindowContent != null)
{' 'wrapperWindow = new Confirm1View() { Confirmation = (IConfirmation)notification };
if (string.IsNullOrEmpty(notification.Title))
{ wrapperWindow.Title = "Confirmation"; }
else
{wrapperWindow.Title = notification.Title;}
//PrepareContentForWindow(notification, wrapperWindow);
return wrapperWindow;}}
public INotification Notification {get ; set; }
public Action FinishInteraction { get; set; } } }
And this is the Confirm1Window.xaml.cs:
public partial class Confirm1View : MetroWindow, IInteractionRequestAware
{
public Confirm1View()
{ InitializeComponent(); }
public IConfirmation Confirmation
{ get
{ return DataContext as IConfirmation; }
set { DataContext = value; }
}
private void OkButtonClick(object sender, RoutedEventArgs e)
{ if (FinishInteraction != null)
FinishInteraction();
Confirmation.Confirmed = true;
Close();
} }
public Action FinishInteraction { get; set; }
public INotification Notification { get; set; } }
I notice that FinishInteraction is always null, so maybe I am missing something. Thank you.