Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

59 rader
1.6 KiB

  1. using System.Windows;
  2. using System.Windows.Input;
  3. namespace BPA.UIControl
  4. {
  5. /// <summary>
  6. /// MessageBoxWindow.xaml 的交互逻辑
  7. /// </summary>
  8. public partial class MessageBoxWindow : Window
  9. {
  10. /// <summary>
  11. /// 消息框结果
  12. /// </summary>
  13. public MessageBoxResult MessageBoxResult { get; set; }
  14. /// <summary>
  15. /// Initializes a new instance of the <see cref="MessageBoxWindow"/> class.
  16. /// </summary>
  17. public MessageBoxWindow()
  18. {
  19. InitializeComponent();
  20. }
  21. /// <summary>
  22. /// 添加消息框
  23. /// </summary>
  24. /// <param name="card">消息框卡片</param>
  25. internal void AddMessageBoxCard(MessageBoxCard card)
  26. {
  27. card.ReturnResult += Card_ReturnResult;
  28. card.Closed += Card_Close;
  29. messageBoxPanel.Child = card;
  30. }
  31. private void Card_ReturnResult(object sender, MessageBoxResultRoutedEventArgs e)
  32. {
  33. MessageBoxResult = e.Result;
  34. }
  35. private void Card_Close(object sender, RoutedEventArgs e)
  36. {
  37. messageBoxPanel.Child = null;
  38. DialogResult = true;
  39. }
  40. private void Window_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
  41. {
  42. _ = Focus();
  43. }
  44. private void Window_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
  45. {
  46. if (e.NewFocus != null)
  47. {
  48. e.Handled = true;
  49. }
  50. }
  51. }
  52. }