Ejemplo n.º 1
0
        public void refresh(object sender, EventArgs e)
        {
            var NewProcesses = new List <Process>(Process.GetProcesses());

            int index = 0;

            Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                ICollectionView view = CollectionViewSource.GetDefaultView(MyListView.ItemsSource);
                index = view.CurrentPosition;
            }));

            lock (ProcessesList)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() => ProcessesList.Clear()));
                foreach (var process in NewProcesses)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() => this.ProcessesList.Add(process)));
                }
            }

            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                ICollectionView view = CollectionViewSource.GetDefaultView(MyListView.ItemsSource);
                view.Refresh();
                try
                {
                    view.MoveCurrentToPosition(index);
                }
                catch (Exception)
                {
                    MyListView.UnselectAll();
                }
            }));
        }
Ejemplo n.º 2
0
 private void StackPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     MyListView.UnselectAll();
 }