Как инициализировать и отправить тост-уведомление - PullRequest
1 голос
/ 24 апреля 2019

Я пытаюсь инициализировать и отправить свое всплывающее уведомление моему uwp и не могу заставить его распознать имя контента, но он всегда рекомендует другое имя контента.

У меня есть XML-файл и C # -файл, которые являются одинаковыми уведомлениями о тостах, и у меня просто возникают проблемы с инициализацией и отправкой его в мое приложение.

Это мой XML-файл

<toast launch ="app-defined-string" scenario="Reminder">
  <visual>
    <binding template ="ToastGeneric">
      <text>Reminder</text>
      <text>Have you set up all of your arrangements for your trip to St. Petersburg yet? The closer you get to the date, the more expensive flights and excursions will cost!</text>
    </binding>
  </visual>
  <actions>
    <action content="Yes I've already made arrangements!" arguments="check" imageUri="check.png"/>
    <action content="No, I haven't yet." arguments="cancel" imageUri="cancel.png"/>
  </actions>
</toast>

Это мой файл C # для примерно того же уведомления

 class ToastNotification
    {
        ToastContent content = new ToastContent()
        {
            Launch = "app-defined string",

            Visual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                     {
                        new AdaptiveText()
                        {
                            Text = "Reminder"
                        },

                        new AdaptiveText()
                        {
                            Text = "Have you set up all of your arrangements for your trip to St. Petersburg yet? The closer you get to the date, the more expensive flights and excursions will cost!"
                        }
                     },
                }

            },


            Actions = new ToastActionsCustom()
            {
                Buttons =
                {
                    new ToastButton("Yes I have, thanks!", "thanks"),
                    new ToastButton("No I have not yet!", "later")
                    {
                        ActivationType = ToastActivationType.Foreground
                    }
                }
            }
        };



    }

Когда я пытаюсь инициализировать его, я пытаюсь сделать это в C #:

XmlDocument xmlContent = content.GetXml();

ToastNotification notification = new ToastNotification(xmlContent);
ToastNotificationManager.CreateToastNotifier().Show(notification);

Проблема, с которой я сталкиваюсь, связана с первой строкой, поскольку она не распознает content.GetXml (); часть; это предложит что-то еще.

...