WinComboBox.xaml.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using FWindSoft.Tools;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Shapes;
  17. namespace Test.SearchControl
  18. {
  19. /// <summary>
  20. /// WinComboBox.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class WinComboBox : Window, INotifyPropertyChanged
  23. {
  24. public WinComboBox()
  25. {
  26. InitializeComponent();
  27. ItemsStr = new List<string>() {"fafa","ccc","ccacac","ddada", "cbacac" };
  28. this.Selected = ItemsStr.FirstOrDefault();
  29. this.DataContext = this;
  30. B b = new B();
  31. var dd = b.Type;
  32. }
  33. public List<string> ItemsStr { get; set; }
  34. public event PropertyChangedEventHandler PropertyChanged;
  35. public void Raise(string name)
  36. {
  37. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
  38. }
  39. private string m_Selected;
  40. public string Selected
  41. {
  42. get { return m_Selected; }
  43. set
  44. {
  45. this.m_Selected = value;
  46. Raise("Selected");
  47. }
  48. }
  49. private void Button_Click(object sender, RoutedEventArgs e)
  50. {
  51. WinProgress winProgress = new WinProgress(); ;
  52. winProgress.Show();
  53. //TaskUtil.StartSTATask(() =>
  54. //{
  55. // winProgress = new WinProgress();
  56. // winProgress.Closed += (d, k) =>
  57. // {
  58. // // 当窗口关闭后马上结束消息循环
  59. // System.Windows.Threading.Dispatcher.ExitAllFrames();
  60. // };
  61. // //m_Win.ShowDialog();
  62. // winProgress.Show();
  63. // //一定要处理退出机制,不然该监控线程不会消失,有时间再研究
  64. // System.Windows.Threading.Dispatcher.Run();
  65. //});
  66. for (int i = 0; i < 1000; i++)
  67. {
  68. //Text.Text = i.ToString();
  69. winProgress.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,new Action<int>((n) =>
  70. {
  71. //this.Dispatcher.Invoke(new Action(() => { }),
  72. // System.Windows.Threading.DispatcherPriority.Background);
  73. winProgress.Content = n.ToString();
  74. }), i);
  75. //winProgress.Dispatcher.Invoke(() =>
  76. //{
  77. // winProgress.Content = Thread.CurrentThread.ManagedThreadId + "----" + i.ToString();
  78. //}, System.Windows.Threading.DispatcherPriority.Background);
  79. Thread.Sleep(10);
  80. }
  81. //for (int i = 1000; i < 2000; i++)
  82. //{
  83. // this.Dispatcher.Invoke(() =>
  84. // {
  85. // Thread.Sleep(10);
  86. // Text.Text = i.ToString();
  87. // }, System.Windows.Threading.DispatcherPriority.Send);
  88. //}
  89. //MessageBox.Show(Selected);
  90. }
  91. }
  92. public class A
  93. {
  94. public A()
  95. {
  96. Type = this.GetType().FullName;
  97. }
  98. public string Type { get; set; }
  99. }
  100. public class B:A
  101. {
  102. }
  103. }