WCF is hosted in WPF and how can I change the controls in MainWindow UI from wcf?

I am writing WCF code and hosted in my WPF application. I am writing a class to switch my MainWindow to show another page in my project

public static class Switcher
    {
        public static MainWindow pageSwitcher;

        public static void Switch(Page newPage)
        {
            pageSwitcher.Navigate(newPage);
        }       
    }

and I write my wcf service as follows:

[ServiceContract]
    public interface IAppManager
    {
        [OperationContract]
        void DoWork();
        [OperationContract]
        void Page1();
        [OperationContract]
        void Page2();
    }
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
    public class AppManager : IAppManager
    {

        public void DoWork()
        {
        }
        public void Page1()
        {
            MainWindow.pageSwitcher = new MainWindow();
            MainWindow.Switch(new Page1());
        }
        public void Page2()
        {
            MainWindow.pageSwitcher = new MainWindow();
            MainWindow.Switch(new Page2());
        }
    }

I want to remotely change the page from another computer using WCF, but it doesn’t work and I trace the start and response wcf code, but I’m not doing anything, how can I go to the main stream to change the ui page or another element?

+4
source share
2 answers

, WCF WPF. WCF - .

, - pub-sub (, MSDN):

enter image description here

-, , Prism EventAggregator. , cherry, PRISMs EventAggregator Prism EventAggregator .

, , , WPF . , .

+2

WCF WPF.

:

1) WCF WPF - .

2) WCF - WCF , .

3) WCF ( ) - , .

- .

Duplex

, ! .

+2

Source: https://habr.com/ru/post/1584616/


All Articles