Toast NotificationsExtensions按钮没有出现

时间:2016-02-19 12:23:24

标签: c# win-universal-app toast

这是我第一次实施 Toast 通知,但我遇到按钮问题:

enter image description here

我正在使用NotificationsExtensions创建Toast通知:

ToastContent tc = new ToastContent()
        {
            Visual = new ToastVisual()
            {
                TitleText = new ToastText() { Text = "Quick Save" },
                BodyTextLine1 = new ToastText() { Text = "Type below the info that you wanna save and press enter" }
            },
            Actions = new ToastActionsCustom()
            {
                Inputs =
                {
                    new ToastTextBox(nameBox)
                    {
                        PlaceholderContent = "type here"
                    }
                },

                Buttons =
                {
                    new ToastButton("save", "save")
                    {
                        TextBoxId = nameBox
                    }
                }
            },
                Duration = ToastDuration.Short
            };

1 个答案:

答案 0 :(得分:2)

您忘记为按钮添加ImageUri

ToastContent tc = new ToastContent()
{
    Visual = new ToastVisual()
    {
        TitleText = new ToastText()
        {
            Text = "Quick Save"
        },
        BodyTextLine1 = new ToastText()
        {
            Text = "Type below the info that you wanna save and press enter"
        }
    },

    Actions = new ToastActionsCustom()
    {
        Inputs =
        {
            new ToastTextBox("nameBox")
            {
                PlaceholderContent = "type here"
            }
        },

        Buttons =
        {
            new ToastButton("save", "save")
            {
                TextBoxId = "nameBox",
                ImageUri = "Assets/check.png"
            }
        }
    }
};

var text = tc.GetContent();
var xml = tc.GetXml();
var toast = new ToastNotification(xml);
ToastNotificationManager.CreateToastNotifier().Show(toast);

enter image description here