Search code examples
c#wpfprism-4

Beginning in Prism


I'm totally new in Prism (Composite Wpf). I want to create messaging module for my application: invisible panel on the top of the main window which appears when I invoke ShowMessage(string message) (and disappears after 5 seconds, for instance).

What I've done:

  • Create infrastructure project (contains only one interface IUIMessagesService)
  • Create module project:

    • Project contains user control - it's panel for the message (View)

    • Project contains UIMessagesService class, which implements IUIMessagesService

    • In module class I did so:

    public UIMessagesModule(IRegionManager regionManager, IUnityContainer container) { _regionManager = regionManager; _container = container; }

and

    public void Initialize()
    {
        _regionManager.RegisterViewWithRegion("UIMessagesRegion", typeof(UIMessagesView));
        _container.RegisterType<IUIMessagesService, UIMessagesService>(new ContainerControlledLifetimeManager());
    }
  • Create shell project (bootstrapper, shell view with region e.t.c)

Questions:

  • How can I change properties of my view in class UIMessagesService (in this case RenderTrasform to show panel)? May be I need define theese properties in view model? How to change view model properties?

  • How to execute module methods ShowMessages from application?


Solution

  • For your first question you can use Event Aggregation
    For second:
    you can use ServiceLocator or container to resolve your type