Click here to Skip to main content
13,202,262 members (53,713 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 6 Sep 2012

[Caliburn.Micro] Passing Control Event to ShellView

, 6 Sep 2012
Rate this:
Please Sign up or sign in to vote.
How to pass Control Event to ShellView (Main Page) using Caliburn.Micro?


In Caliburn.Micro, we have a series of supporting services for building presentation tiers. Among them is the EventAggregator, a service which supports in-process publish/subscribe. Here I explain how to pass (Publish) event from Control to Main Page (ShellView) and How to subscribe event in ShellviewModel.

Let’s start by having a look at the ItemClickEvent class:

First add ItemClickEvent class and write there:

public string ToDoItemDescription { get; set; }

public ItemClickEvent(string toDoItemDescription)
	ToDoItemDescription = toDoItemDescription;

After creating ItemClassEvent class, add new Item PageOneView which contains a Simple Button and add PageOneViewModel which contains Button click like:

public class PageOneViewModel : Conductor<screen>.Collection.OneActive
	public void ClickMe()
       	IoC.Get<ieventaggregator>().Publish(new ItemClickEvent("Button Click"));
		// Here you can pass your custom value and variable in ItemClassEvent().

Finally ShellViewModel looks like:

namespace EventPassingToShellView
    public class ShellViewModel : Conductor<screen>
    .Collection.OneActive, IShell, IHandle<itemclickevent>
        public ShellViewModel()

        public void ShowPageOne()
            ActivateItem(new PageOneViewModel());
        #region IHandle<itemclickevent> Members

        public void Handle(ItemClickEvent message)
		// Got message from  PageOneViewModel what ever you pass it.


Finally Project Structure looks like:

Project Structure


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Savalia Manoj M
Software Developer (Senior)
India India
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionGoing the other way Pin
DBLWizard28-Nov-12 12:00
memberDBLWizard28-Nov-12 12:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171020.1 | Last Updated 7 Sep 2012
Article Copyright 2012 by Savalia Manoj M
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid