Subscribe event when new module is loaded

2 posts, 0 answers
  1. Adam
    Adam avatar
    4 posts
    Member since:
    Dec 2012

    Posted 27 Jan 2013 Link to this post

    Hello, I have C# Silverlight PRISM application with couple modules. I would like to ask you how to solve this situation: 

    1) Module Projects is loaded by default, when user select a project then event is fired in SelectedProject property.

            public ProjectItem SelectedProject
            {   get
                {
                    return selectedProject;
                }
                set
                {   if (selectedProject != value)
                    {
                        selectedProject = value;
                        OnPropertyChanged(() => SelectedProject);
                        eventAggregator.GetEvent<ProjectSelectedEvent>().Publish(selectedProject);
                    }
                }
            }

    2) user click a button "Show Tasks for Project" on a Ribbon and application is now loading a module Tasks using RegisterViewWithRegion, in constructor I'm subscribing event.

            public ProjectTasksViewModel(IEventAggregator eventAggregator)
            {
                this.eventAggregator = eventAggregator;
                this.eventAggregator.GetEvent<ProjectSelectedEvent>().Subscribe(ProjectSelectedEventSubscribed);
            }

    So when Tasks module is loaded none event is subscribed. Of course if I force publishing this event by selecting a project again this code will work perfectly.

    But I need to know how to do this automatically when Task module is loaded it knows what project-related tasks it should display.

  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 30 Jan 2013 Link to this post

    Hello Adam,

    As these questions are mostly related to the PRISM pattern, it would be better to post them in PRISM-related forums - for example in the CodePlex PRISM discussions board.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top