c# wpf command pattern
        Posted  
        
            by evan
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by evan
        
        
        
        Published on 2010-04-15T17:39:17Z
        Indexed on 
            2010/04/15
            17:43 UTC
        
        
        Read the original article
        Hit count: 255
        
I have a wpf gui which displays a list of information in separate window and in a separate thread from the main application. As the user performs actions in the main window the side window is updated. (For example if you clicked page down in the main window a listbox in the side window would page down).
Right now the architecture for this application feels very messy and I'm sure there is a cleaner way to do it. It looks like this:
Main Window contains a singleton SideWindowControl which communicates with an instance of the SideWindowDisplay using events - so, for example, the pagedown button would work like:
1) the event handler of the button on the main window calls SideWindowControl.PageDown()
2) in the PageDown() function a event is created and thrown.
3) finally the gui, ShowSideWindowDisplay is subscribing to the SideWindowControl.Actions event handles the event and actually scrolls the listbox down - note because it is in a different thread it has to do that by running the command via Dispatcher.Invoke()
This just seems like a very messy way to this and there must be a clearer way (The only part that can't change is that the main window and the side window must be on different threads). Perhaps using WPF commands?
I'd really appreciate any suggestions!! Thanks
© Stack Overflow or respective owner