title: Xamarin dismiss popup window
body: <p>I have an issue , when SavedAyasListView_ItemLongClick event fires, a popupwindow appears with some buttons, and my intention is whenever i click btnDeleteAya button , perform some actions and dismiss the popup.
  When the event fires, the popup appears and when i click the btnDeleteAya the action gets performed and the popup disappears, but when i do the same thing again the popup window doesnt get closed.
  I want it to get closed each time i click the btnDeleteAya button not by just clicking outside because that part works as expected.
  Here's the code:</p>
  
  <pre><code>        public string itemclicked;
          PopupWindow mpopup;
          private void SavedAyasListView_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
          {
              View popUpView = LayoutInflater.Inflate(Resource.Layout.SavedAyasPopupMenu,
              null); // inflating popup layout
              mpopup = new PopupWindow(popUpView, 800, 500); // Creation of popup
              mpopup.SetBackgroundDrawable(new BitmapDrawable());
              mpopup.OutsideTouchable = true;
              mpopup.Focusable = true;
              mpopup.ShowAtLocation(popUpView, GravityFlags.Center, 10, 50);
              itemclicked = savedAyasListView.GetItemAtPosition(e.Position).ToString();
  
              Button btnDeleteAya = popUpView.FindViewById&lt;Button&gt;(Resource.Id.btnDeleteAya);
              btnDeleteAya.Click += BtnDeleteAya_Click;
              btnDeleteAya.Click += delegate
              {
                  mpopup.Dismiss();
              };
  
              Button fbShareSavedAya = popUpView.FindViewById&lt;Button&gt;(Resource.Id.fbShareSavedAya);
              fbShareSavedAya.Click += FbShareSavedAya_Click;
  
          }
  </code></pre>