WPF
-
dataGrid.Items 默认选中第一行
Dispatcher.Invoke(new Action(delegate() { //Utility.SelectRowByIndex(this.dataGrid,0,true); dataGrid.SelectedIndex = 0; }),System.Windows.Threading.DispatcherPriority.ContextIdle);
-
反射 返回列 乱序问题
PropertyInfo [] headerList = typeof(T).GetProperties().OrderBy(x => x.MetadataToken).ToArray() ;
-
启动一个定时器,重置光标
System.Timers.Timer timer = new System.Timers.Timer(300); timer.Elapsed += new System.Timers.ElapsedEventHandler((a,b) => { Dispatcher.Invoke((Action)(() => { dataGrid.Focus(); timer.Enabled = false; timer.Stop(); timer.Dispose(); //便于GC回收 timer=null; })); }); timer.AutoReset = false; timer.Enabled = true;