This is a migrated thread and some comments may be shown as answers.

Subscribe event when new module is loaded

1 Answer 37 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 27 Jan 2013, 12:05 PM

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.

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 30 Jan 2013, 05:15 PM
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.

Tags
General Discussions
Asked by
Adam
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or