private void InAppNotificationDismiss(InAppNotification inAppNotification)//Notification:通知驳回
        {
            inAppNotification.Dismiss();

            AdaptiveGridViewControl.IsItemClickEnabled = true;                       //可点击
            AdaptiveGridViewControl.SelectionMode      = ListViewSelectionMode.None; //无选状态

            PhotoFileList.Add(AddPhotoFile);                                         //空白添加:添加
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Shell.Current.RegisterNewCommand("Show notification with random text", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                var random = new Random();
                int result = random.Next(1, 4);

                if (result == 1)
                {
                    _exampleInAppNotification?.Show("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sollicitudin bibendum enim at tincidunt. Praesent egestas ipsum ligula, nec tincidunt lacus semper non.", NotificationDuration);
                }

                if (result == 2)
                {
                    _exampleInAppNotification?.Show("Pellentesque in risus eget leo rhoncus ultricies nec id ante.", NotificationDuration);
                }

                if (result == 3)
                {
                    _exampleInAppNotification?.Show("Sed quis nisi quis nunc condimentum varius id consectetur metus. Duis mauris sapien, commodo eget erat ac, efficitur iaculis magna. Morbi eu velit nec massa pharetra cursus. Fusce non quam egestas leo finibus interdum eu ac massa. Quisque nec justo leo. Aenean scelerisque placerat ultrices. Sed accumsan lorem at arcu commodo tristique.", NotificationDuration);
                }
            });

            Shell.Current.RegisterNewCommand("Show notification with buttons (without DataTemplate)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                var grid = new Grid();

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });

                // Text part
                var textBlock = new TextBlock
                {
                    Text = "Do you like it?",
                    VerticalAlignment = VerticalAlignment.Center
                };
                grid.Children.Add(textBlock);

                // Buttons part
                var stackPanel = new StackPanel
                {
                    Orientation       = Orientation.Horizontal,
                    VerticalAlignment = VerticalAlignment.Center
                };

                var yesButton = new Button
                {
                    Content = "Yes",
                    Width   = 150,
                    Height  = 30
                };
                yesButton.Click += YesButton_Click;
                stackPanel.Children.Add(yesButton);

                var noButton = new Button
                {
                    Content = "No",
                    Width   = 150,
                    Height  = 30,
                    Margin  = new Thickness(10, 0, 0, 0)
                };
                noButton.Click += NoButton_Click;
                stackPanel.Children.Add(noButton);

                Grid.SetColumn(stackPanel, 1);
                grid.Children.Add(stackPanel);

                _exampleInAppNotification?.Show(grid, NotificationDuration);
            });

            Shell.Current.RegisterNewCommand("Show notification with buttons (with DataTemplate)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                object inAppNotificationWithButtonsTemplate = null;
                bool?isTemplatePresent = _resources?.TryGetValue("InAppNotificationWithButtonsTemplate", out inAppNotificationWithButtonsTemplate);

                if (isTemplatePresent == true && inAppNotificationWithButtonsTemplate is DataTemplate template)
                {
                    _exampleInAppNotification.Show(template, NotificationDuration);
                }
            });

            Shell.Current.RegisterNewCommand("Show notification with Drop Shadow (based on default template)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification.Dismiss();

                // Update control template
                object inAppNotificationDropShadowControlTemplate = null;
                bool?isTemplatePresent = _resources?.TryGetValue("InAppNotificationDropShadowControlTemplate", out inAppNotificationDropShadowControlTemplate);

                if (isTemplatePresent == true && inAppNotificationDropShadowControlTemplate is ControlTemplate template)
                {
                    _exampleInAppNotification.Template = template;
                }

                _exampleInAppNotification.Show(NotificationDuration);
            });

            Shell.Current.RegisterNewCommand("Show notification with Visual Studio Code template (info notification)", (sender, args) =>
            {
                _exampleInAppNotification.Dismiss();
                _exampleVSCodeInAppNotification.Show(NotificationDuration);
            });

            Shell.Current.RegisterNewCommand("Dismiss", (sender, args) =>
            {
                // Dismiss all notifications (should not be replicated in production)
                _exampleInAppNotification.Dismiss();
                _exampleVSCodeInAppNotification.Dismiss();
            });
        }
 private void YesButton_Click(object sender, RoutedEventArgs e)
 {
     _exampleInAppNotification?.Dismiss();
 }
        private void Load()
        {
            SampleController.Current.RegisterNewCommand("Show notification with random text", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();
                _exampleInAppNotification?.Show(GetRandomText(), NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Show notification with object", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                var random = new Random();
                _exampleInAppNotification?.Show(new KeyValuePair <int, string>(random.Next(1, 10), GetRandomText()), NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Show notification with buttons (without DataTemplate)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                var grid = new Grid()
                {
                    Margin = new Thickness(0, 0, -38, 0)
                };

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });

                // Text part
                var textBlock = new TextBlock
                {
                    Text = "Do you like it?",
                    VerticalAlignment = VerticalAlignment.Center,
                    Margin            = new Thickness(0, 0, 24, 0),
                    FontSize          = 16
                };
                grid.Children.Add(textBlock);

                // Buttons part
                var stackPanel = new StackPanel
                {
                    Orientation       = Orientation.Horizontal,
                    VerticalAlignment = VerticalAlignment.Center
                };

                var yesButton = new Button
                {
                    Content  = "Yes",
                    Width    = 120,
                    Height   = 40,
                    FontSize = 16
                };
                yesButton.Click += YesButton_Click;
                stackPanel.Children.Add(yesButton);

                var noButton = new Button
                {
                    Content  = "No",
                    Width    = 120,
                    Height   = 40,
                    FontSize = 16,
                    Margin   = new Thickness(4, 0, 0, 0)
                };
                noButton.Click += NoButton_Click;
                stackPanel.Children.Add(noButton);

                Grid.SetColumn(stackPanel, 1);
                grid.Children.Add(stackPanel);

                _exampleInAppNotification?.Show(grid, NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Show notification with buttons (with DataTemplate)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetCustomControlTemplate(); // Use the custom template without the Dismiss button. The DataTemplate will handle re-adding it.

                object inAppNotificationWithButtonsTemplate = null;
                bool?isTemplatePresent = _resources?.TryGetValue("InAppNotificationWithButtonsTemplate", out inAppNotificationWithButtonsTemplate);

                if (isTemplatePresent == true && inAppNotificationWithButtonsTemplate is DataTemplate template)
                {
                    _exampleInAppNotification.Show(template, NotificationDuration);
                }
            });

            SampleController.Current.RegisterNewCommand("Show notification with Drop Shadow (based on default template)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification.Dismiss();
                SetDefaultControlTemplate();

                // Update control template
                object inAppNotificationDropShadowControlTemplate = null;
                bool?isTemplatePresent = _resources?.TryGetValue("InAppNotificationDropShadowControlTemplate", out inAppNotificationDropShadowControlTemplate);

                if (isTemplatePresent == true && inAppNotificationDropShadowControlTemplate is ControlTemplate template)
                {
                    _exampleInAppNotification.Template = template;
                }

                _exampleInAppNotification.Show(GetRandomText(), NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Show notification with Visual Studio Code template (info notification)", (sender, args) =>
            {
                _exampleInAppNotification.Dismiss();
                _exampleVSCodeInAppNotification.Show(NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Dismiss", (sender, args) =>
            {
                // Dismiss all notifications (should not be replicated in production)
                _exampleInAppNotification.Dismiss();
                _exampleVSCodeInAppNotification.Dismiss();
            });
        }
 public static void Dismiss()
 {
     _inAppNotification.Dismiss();
 }