Template / methodology for the interaction between Windows and / or UserControls

I am currently developing an application in which I will have several windows open using C # and WPF.

Is there a template or general methodology used to facilitate communication between open Windows and / or UserControls?

For example, a window, call it β€œHierarchy Window,” can display the hierarchy of countries, provinces, and cities in the world. In addition, there are several other windows that can display a province or city, for example, OR allow you to create a province or city. In the case of creating a new city, which is the best way for my "City Window" to communicate with my "Hierarachy Window" regarding adding a city or deleting a city?

Remembering that the "Hierarchy" window may not even open when creating the City. At this point, there is no need for a response / action.

+3
source share
4 answers

There are two general approaches to this:

  • Use dependency injection to inject shared service.
  • Use a messenger of some form.

The second option is becoming very popular with WPF and Silverlight. Many common tools, such as MVVM Light (see Messenger Class Description for details ), use this approach.

+1
source

Just adding to what Reid wrote above:

( MVVM), Messenger/Mediator, , Injection Dependency.

"" MVVM , Cinch ( V2 ). , - . Microsoft Dev Lab Reactive Extensions .NET, IObservable IObserver - .

Injection Dependency Microsoft Unity Application Bloc k stuff

, .

0

PRISM ( WinForms CAB - Composite Application Block). Microsoft.
  :

//publish:
 eventAggregator.GetEvent<ItemAddedEvent>().Publish(MyItem);

//subscribe:
eventAggregator.GetEvent<ItemAddedEvent>().Subscribe(MyMethod);

, DI, Commands Validation. !

0

, Model-View-Presenter. . MVP MSDN.

0

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


All Articles