示例#1
0
 /// <summary>
 /// 发出通知
 /// </summary>
 /// <param name="data"></param>
 void SendMessage(NotifyData data)
 {
     //此处调用Invoke,否则会报错:“ 调用线程必须为 STA,因为许多 UI 组件都需要 ”。
     App.Current.Dispatcher.Invoke(() =>
     {
         showNotify(data);
     });
 }
示例#2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            i++;
            NotifyData data = new NotifyData();

            data.Title   = "这是标题:" + i;
            data.Content = "这是手动内容 ";
            showNotify(data);
        }
示例#3
0
        private void showNotify(NotifyData data)
        {
            NotificationWindow dialog = new NotificationWindow();//new 一个通知

            dialog.Closed     += Dialog_Closed;
            dialog.TopFrom     = GetTopFrom();
            dialog.DataContext = data;//设置通知里要显示的数据
            dialog.Show();

            _dialogs.Add(dialog);
        }