private void UID(object sender, RoutedEventArgs e) { try { Image IMA = e.OriginalSource as Image; ContentPresenter cp = IMA.TemplatedParent as ContentPresenter; ListViewItem lvi = this.listViewProcess.ItemContainerGenerator.ContainerFromItem(cp.Content) as ListViewItem; Canvas oioi = FindVisualChild <Canvas>(lvi); StackPanel St = FindVisualChild <StackPanel>(lvi); if (FindVisualChild <ListView>(St) != null) { ListView UIDlist = FindVisualChild <ListView>(St); St.Children.Remove(UIDlist); this.GridView1.Columns[0].Width = 50; } else { ListView UIDlist = new ListView(); UIDlist.Width = 1000; this.GridView1.Columns[0].Width = 1100; UIDlist.Name = "UIDlist"; object u = cp.Content; int Pid = Convert.ToInt32(s_文本操作.Between(this.listViewProcess.SelectedItem.ToString(), "PDid = ", ", Tiele1")); for (int y = 0; y <= a.Length; y++) { if (a[y].Id == Pid) { ProcessThreadCollection o = a[y].Threads; ListViewItem item = new ListViewItem(); item.Height = 25; item.Background = Brushes.Orange; item.Content = "UID StartAddress PriorityBoostEnabled PriorityLevel PrivilegedProcessorTime StartTime ThreadState WaitReason "; UIDlist.Items.Add(item); UIDlist.Height = o.Count + 170; for (int t = 0; y < o.Count; t++) { if (t == o.Count) { break; } item = new ListViewItem(); item.Content = string.Format("{0} {1} {2} {3} {4} {5} {6} {7}", o[t].Id.ToString(), o[t].StartAddress.ToString(), o[t].PriorityBoostEnabled.ToString(), o[t].PriorityLevel.ToString(), o[t].PrivilegedProcessorTime.ToString(), o[t].StartTime.ToString(), o[t].ThreadState.ToString(), o[t].WaitReason.ToString()); UIDlist.Items.Add(item); } St.Children.Add(UIDlist); DoubleAnimation da = new DoubleAnimation(); da.From = 0; //起始值 da.To = 1; //结束值 da.Duration = TimeSpan.FromSeconds(2); //动画持续时间 UIDlist.BeginAnimation(TextBlock.OpacityProperty, da); //开始动画 lvi.BeginAnimation(TextBlock.OpacityProperty, da); //开始动画 ThicknessAnimation ta = new ThicknessAnimation(); ta.From = new Thickness(-200, 0, 0, 0); //起始值 ta.To = new Thickness(0, 0, 0, 0); //结束值 ta.Duration = TimeSpan.FromSeconds(1); //动画持续时间 lvi.BeginAnimation(TextBlock.MarginProperty, ta); //开始动画 ta.From = new Thickness(400, 0, 0, 0); //起始值 ta.To = new Thickness(0, 0, 0, 0); //结束值 ta.Duration = TimeSpan.FromSeconds(2); //动画持续时间 UIDlist.BeginAnimation(TextBlock.MarginProperty, ta); //开始动画 return; } } } } catch { } /*自绘标签和按钮方案 * { * if (FindVisualChild<TextBlock>(St) != null) * { * TextBlock i = FindVisualChild<TextBlock>(St); * St.Children.Remove(i); * St.UnregisterName("i"); * } * else * { * * TextBlock UID = new TextBlock(); * UID.Text = "UID "; * UID.Name = "i"; * UID.Width = 50; * UID.Height = 50; * St.RegisterName("i", UID); * St.Children.Add(UID); * * TextBlock yxj = new TextBlock(); * yxj.Text = "优先级"; * yxj.Name = "yxj"; * yxj.Width = 100; * St.Children.Add(yxj); * } * }*/ }