Modify an invisible ContextPopup
authorGeunsun, Lee <gs86.lee@samsung.com>
Thu, 6 Apr 2017 05:55:57 +0000 (14:55 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:52 +0000 (18:34 +0900)
Change-Id: I5a4b30938062aed964aebbc72004f4118d6be4de

TVApps/TVApps/Views/FooterNormalStatus.xaml.cs

index adb9031..ec7e207 100644 (file)
@@ -27,9 +27,11 @@ namespace TVApps.Views
     /// </summary>
     public partial class FooterNormalStatus : Grid
     {
-        static ContextPopup popup;
         private bool isPopupShowing = false;
 
+        /// <summary>
+        /// A command will be executed if the Pin option is selected
+        /// </summary>
         public static readonly BindableProperty PinAppCommandProperty = BindableProperty.Create("PinAppCommand", typeof(Command), typeof(FooterNormalStatus), null);
         public ICommand PinAppCommand
         {
@@ -37,6 +39,9 @@ namespace TVApps.Views
             set { SetValue(PinAppCommandProperty, value); }
         }
 
+        /// <summary>
+        /// A command will be executed if the Delete option is selected
+        /// </summary>
         public static readonly BindableProperty DeleteAppCommandProperty = BindableProperty.Create("DeleteAppCommand", typeof(Command), typeof(FooterNormalStatus), null);
         public ICommand DeleteAppCommand
         {
@@ -44,15 +49,22 @@ namespace TVApps.Views
             set { SetValue(DeleteAppCommandProperty, value); }
         }
 
-
         /// <summary>
         /// A constructor
         /// </summary>
         public FooterNormalStatus()
         {
             InitializeComponent();
+        }
 
-            popup = new ContextPopup
+        void OnOptionsClicked(object sender, EventArgs e)
+        {
+            if (isPopupShowing)
+            {
+                return;
+            }
+
+            ContextPopup popup = new ContextPopup
             {
                 IsAutoHidingEnabled = true,
                 Orientation = ContextPopupOrientation.Vertical,
@@ -63,17 +75,19 @@ namespace TVApps.Views
             popup.Items.Add(new ContextPopupItem("DELETE"));
 
             //TODO: need to change the event callback
-            popup.SelectedIndexChanged += (s, e) =>
+            popup.SelectedIndexChanged += (s, args) =>
             {
                 var ctxPopup = s as ContextPopup;
 
                 DebuggingUtils.Dbg("selected item : " + (ctxPopup.SelectedItem as ContextPopupItem).Label + " (" + ctxPopup.SelectedIndex + ")");
                 switch (ctxPopup.SelectedIndex)
                 {
-                    case 0: //PIN
+                    case 0:
+                        //PIN
                         PinAppCommand?.Execute("");
                         break;
-                    case 1: //DELETE
+                    case 1:
+                        //DELETE
                         DeleteAppCommand?.Execute("");
                         break;
                     default:
@@ -83,18 +97,10 @@ namespace TVApps.Views
                 popup.Dismiss();
             };
 
-            popup.Dismissed += (s, e) =>
+            popup.Dismissed += (s, args) =>
             {
                 isPopupShowing = false;
             };
-        }
-
-        void OnOptionsClicked(object sender, EventArgs e)
-        {
-            if (isPopupShowing)
-            {
-                return;
-            }
 
             popup.Show(sender as View);
             isPopupShowing = true;