Ejemplo n.º 1
0
        private void NewToast_HideCompleted(object sender, RoutedEventArgs e)
        {
            //ToastItemsControl.Items.Remove(sender);
            AllToasts.Remove((MaterialFrame)sender);

            if (AllToasts.Count == 0)
            {
                NotificationLayoutAnchor.Hide();
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        private void NumToastsButton_Click(object sender, RoutedEventArgs e)
        {
            // After user has manually closed the anchor, we need to re-add it to display it
            if (NotificationLayoutAnchor.Parent == null)
            {
                NotificationLayoutAnchor.Parent = NotificationLayoutAnchorParent;
                NotificationLayoutAnchorParent.Children.Add(NotificationLayoutAnchor);
            }

            if (NotificationLayoutAnchor.IsAutoHidden)
            {
                NotificationLayoutAnchor.ToggleAutoHide();
            }

            if (!NotificationLayoutAnchor.IsVisible || NotificationLayoutAnchor.IsHidden)
            {
                NotificationLayoutAnchor.Show();
            }
        }