public void SentToast() { ToastContent content = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = new BindableString("cuurrentfile") },
new AdaptiveProgressBar() { Title = "Copy", Value = new BindableProgressBarValue("progressValue"), ValueStringOverride =new BindableString("progressValueString"), Status =new BindableString("progressStatus") } } } } };
// Generate the toast notification var toast = new ToastNotification(content.GetXml()) {
// Assign the tag and group Tag = Source.Path, Group = "Copy",
// Assign initial NotificationData values // Values must be of type string Data = new NotificationData() }; toast.Data.Values["progressValue"] = "0"; toast.Data.Values["progressValueString"] = "/ "; toast.Data.Values["progressStatus"] = "Copying..."; toast.Data.Values["cuurrentfile"] = ""; // Provide sequence number to prevent out-of-order updates, or assign 0 to indicate "always update" toast.Data.SequenceNumber = 1;
// Show the toast notification to the user ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void UpdateProgress() { // Construct a NotificationData object; string tag = Source.Path; string group = "Copy";
// Create NotificationData and make sure the sequence number is incremented // since last update, or assign 0 for updating regardless of order var data = new NotificationData { SequenceNumber = 2 };
// Assign new values // Note that you only need to assign values that changed. In this example // we don't assign progressStatus since we don't need to change it data.Values["progressValue"] = (CurrentProgress/100).ToString(); data.Values["progressValueString"] = fileID+1+"/"+filecount+"files"; data.Values["cuurrentfile"] = CurrentFileName; data.Values["progressStatus"] = CurrentCopyStatus.ToString(); // Update the existing notification's data by using tag/group ToastNotificationManager.CreateToastNotifier().Update(data, tag, group); }