title: WPF - PRISM: How to close CustomPopupWindow with button click
body: <p>This one is playing with me, and I cannot seem to figure it out - I need some external help here bro's!</p>
  
  <p>I want a popup window that does not have the title, minimize, maximize, and close buttons, because we want to style it ourselves and add a custom close button on the popup's screen.</p>
  
  <p>So I followed these links to get where I am now:</p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/ff921081(v=pandp.40).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/ff921081(v=pandp.40).aspx</a>
  <a href="https://msdn.microsoft.com/en-us/library/gg405494(v=pandp.40).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/gg405494(v=pandp.40).aspx</a>
  <a href="https://www.codeproject.com/Articles/269364/MVVM-PRISM-Modal-Windows-by-using-Interaction-Requ" rel="nofollow noreferrer">https://www.codeproject.com/Articles/269364/MVVM-PRISM-Modal-Windows-by-using-Interaction-Requ</a></p>
  
  <p>But I still can't figure out how to achieve this. The basic windows have "OK" and "Cancel" buttons, but those are defaults, and I do not want that, that is why I went the "Custom View" way.</p>
  
  <p>Here is my Main Window's xaml:</p>
  
  <pre><code>&lt;Window x:Class="Prototype.Views.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:prism="http://prismlibrary.com/"
          prism:ViewModelLocator.AutoWireViewModel="True"
          xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
          xmlns:views="clr-namespace:Prototype.Views"
          Height="349.146" Width="727.317"
          WindowState="Maximized"&gt;
      &lt;Grid&gt;
          &lt;Button Command="{Binding RaiseCustomPopupViewCommand}"&gt;Show Popup Window&lt;/Button&gt;
  
          &lt;i:Interaction.Triggers&gt;
              &lt;prism:InteractionRequestTrigger SourceObject="{Binding CustomPopupViewRequest, Mode=OneWay}"&gt;
                  &lt;prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True"&gt;
                      &lt;prism:PopupWindowAction.WindowStyle&gt;
                          &lt;Style TargetType="Window"&gt;
                              &lt;Setter Property="ShowInTaskbar" Value="False"/&gt;
                              &lt;Setter Property="WindowStyle" Value="None"/&gt;
                              &lt;Setter Property="ResizeMode" Value="NoResize"/&gt;
                          &lt;/Style&gt;
                      &lt;/prism:PopupWindowAction.WindowStyle&gt;
                      &lt;prism:PopupWindowAction.WindowContent&gt;
                          &lt;views:CustomPopupView  /&gt;
                      &lt;/prism:PopupWindowAction.WindowContent&gt;
                  &lt;/prism:PopupWindowAction&gt;
              &lt;/prism:InteractionRequestTrigger&gt;
          &lt;/i:Interaction.Triggers&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>And here it the Main Window's code:</p>
  
  <pre><code>public class MainWindowViewModel : BindableBase
  {
      public InteractionRequest&lt;INotification&gt; CustomPopupViewRequest { get; private set; }
  
      public MainWindowViewModel()
      {
          CustomPopupViewRequest = new InteractionRequest&lt;INotification&gt;();
      }
  
      public DelegateCommand RaiseCustomPopupViewCommand =&gt; new DelegateCommand(RaiseCustomPopupView, CanRaiseCustomPopupView);
  
      public string InteractionResultMessage { get; private set; }
  
      private void RaiseCustomPopupView()
      {
          InteractionResultMessage = "";
          CustomPopupViewRequest.Raise(new Notification { Content = "Message for the CustomPopupView", Title = "Custom Popup" });
      }
  
      private bool CanRaiseCustomPopupView()
      {
          return true;
      }
  }
  </code></pre>
  
  <p>The <code>InteractionRequestTrigger</code>'s SourceObject is a UserControl. </p>
  
  <p>Here is it's xaml:</p>
  
  <pre><code>&lt;UserControl x:Class="Prototype.Views.CustomPopupView"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               xmlns:prism="http://prismlibrary.com/"
               prism:ViewModelLocator.AutoWireViewModel="True"
               xmlns:local="clr-namespace:Prototype.Views"
               mc:Ignorable="d" 
               d:DesignHeight="300" d:DesignWidth="300"
               MinWidth="300" MinHeight="100"&gt;
      &lt;StackPanel Orientation="Vertical" Background="Gray"&gt;
          &lt;Button DockPanel.Dock="Right"
                  Content="Close"/&gt;
      &lt;/StackPanel&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>So as you can see, I have a "Close" button in the UserControl.</p>
  
  <p>I tried using a Command, but even then I cannot acccess the window or execute something to close the window.</p>
  
  <p>Is there some kind of prism command or something I am not aware of?</p>
  
  <p>Is it possible to close the window the way I want with a button?</p>
  
  <p>Any help will be greatly appreciated! :)</p>