using FWindSoft.Tools; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace Test.SearchControl { /// /// WinComboBox.xaml 的交互逻辑 /// public partial class WinComboBox : Window, INotifyPropertyChanged { public WinComboBox() { InitializeComponent(); ItemsStr = new List() {"fafa","ccc","ccacac","ddada", "cbacac" }; this.Selected = ItemsStr.FirstOrDefault(); this.DataContext = this; B b = new B(); var dd = b.Type; } public List ItemsStr { get; set; } public event PropertyChangedEventHandler PropertyChanged; public void Raise(string name) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } private string m_Selected; public string Selected { get { return m_Selected; } set { this.m_Selected = value; Raise("Selected"); } } private void Button_Click(object sender, RoutedEventArgs e) { WinProgress winProgress = new WinProgress(); ; winProgress.Show(); //TaskUtil.StartSTATask(() => //{ // winProgress = new WinProgress(); // winProgress.Closed += (d, k) => // { // // 当窗口关闭后马上结束消息循环 // System.Windows.Threading.Dispatcher.ExitAllFrames(); // }; // //m_Win.ShowDialog(); // winProgress.Show(); // //一定要处理退出机制,不然该监控线程不会消失,有时间再研究 // System.Windows.Threading.Dispatcher.Run(); //}); for (int i = 0; i < 1000; i++) { //Text.Text = i.ToString(); winProgress.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,new Action((n) => { //this.Dispatcher.Invoke(new Action(() => { }), // System.Windows.Threading.DispatcherPriority.Background); winProgress.Content = n.ToString(); }), i); //winProgress.Dispatcher.Invoke(() => //{ // winProgress.Content = Thread.CurrentThread.ManagedThreadId + "----" + i.ToString(); //}, System.Windows.Threading.DispatcherPriority.Background); Thread.Sleep(10); } //for (int i = 1000; i < 2000; i++) //{ // this.Dispatcher.Invoke(() => // { // Thread.Sleep(10); // Text.Text = i.ToString(); // }, System.Windows.Threading.DispatcherPriority.Send); //} //MessageBox.Show(Selected); } } public class A { public A() { Type = this.GetType().FullName; } public string Type { get; set; } } public class B:A { } }