private void NewToast_HideCompleted(object sender, RoutedEventArgs e) { //ToastItemsControl.Items.Remove(sender); AllToasts.Remove((MaterialFrame)sender); if (AllToasts.Count == 0) { NotificationLayoutAnchor.Hide(); } }
private void ClearAllNotificationsButton_Click(object sender, RoutedEventArgs e) { List <MaterialFrame> toastsToRemove = AllToasts.ToList(); foreach (MaterialFrame toast in toastsToRemove) { //toast.HideToast(); toast.Visibility = Visibility.Collapsed; AllToasts.Remove(toast); } toastsToRemove.Clear(); toastsToRemove = null; }
private void ToastButton_Click(object sender, RoutedEventArgs e) { //MaterialToast newToast = new MaterialToast(); //ToastListView.Items.Add(newToast); //MaterialToast newToast = new MaterialToast(ToastItemsControl); //AllToasts.Add(newToast); MaterialFrame newToast = new MaterialFrame(); AllToasts.Add(newToast); ////newToast.DisplayTime = new TimeSpan(0, 0, 1); //newToast.HideCompleted += NewToast_HideCompleted; //newToast.IsCloseButtonVisible = true; //newToast.HideOnClick = true; newToast.ToolTip = DateTime.Now.ToString(); //newToast.Content = Resources["ToastContent"]; // [System.Windows.ControlTemplate] //newToast.Template = (ControlTemplate)Resources["ToastContent"]; // Replaced style, lost close button //newToast.Content = "This is my content."; // Embeds string inside xceed toast //newToast.Content = new Rectangle() { Width = 20, Height = 20, Fill = Brushes.Aqua }; // Embeds aqua rect inside xceed toast ////////// WORKS VIA XAML //////////////////// newToast.ContentTemplate = (DataTemplate)Resources["ToastContent"]; ////////////////////////////////////////////////////////// ////////// WORKS VIA FULL CODE BEHIND //////////////////// //StackPanel toastStack = new StackPanel(); //toastStack.Orientation = Orientation.Vertical; //toastStack.Children.Add(new TextBlock() { Text = "This is my Title" }); //toastStack.Children.Add(new TextBlock() { Text = "This is my Content" }); //toastStack.Children.Add(new TextBlock() { Text = DateTime.Now.TimeOfDay.ToString(@"mm\:ss\.ff") }); //newToast.Content = toastStack; ////////////////////////////////////////////////////////// if (NotificationLayoutAnchor.IsHidden) { NotificationLayoutAnchor.Show(); } if (ToastItemsControl.IsVisible) { //newToast.ShowToast(); } }