locked
How to handle nested UI Process in WPF c# RRS feed

  • Question

  • I have two listview controls are placed in two WPF windows respectively, first listview is in main window of application, if click the its child listview item it will trigger to open the child window which has my second listview control, it my application architecture.

    My Query is

    How to handle two nested UI process programmatically

    1. I need to select all listview item programmatically in main window with corresponding child window.

    Example: In Main Window, If first listview item is being selected, then it triggers its child window to open and it need to select all listview items in child window, once it is completed , now child window needs to close then , next list view item needs to be select in main window.

    Currently following below methods to achieve this, but fails

    Code

    private void MainWindowLoaded(object param) {
     
       ListView listView = param as ListView;
     
       foreach(ListViewItem item in listView.Items) {
         DemosNavigationService.MainWindow.Dispatcher.BeginInvoke(new Action(() =>{
           foreach(var window in this.ChildWindows) {
             window.Close();
           }
           listView.SelectedItem = item;
     
         }), System.Windows.Threading.DispatcherPriority.Normal);
       }
     
     }
     
     private void ChildWindowLoaded(object param) {
       ListView listView = param as ListView;
     
       foreach(ListViewItem item in listView.Items) {
         DemosNavigationService.MainWindow.Dispatcher.BeginInvoke(new Action(() =>{
     
           listView.SelectedItem = item;
     
         }), System.Windows.Threading.DispatcherPriority.Loaded);
       }
     }

    Any alternate way to achieve my requirement?

    Monday, October 26, 2020 7:35 AM

All replies

  • This forum is for C#-specific questions only. Please post questions related to WPF in the Microsoft Q&A forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, October 26, 2020 1:47 PM