MDI in caliburn, add new tab item to tab control but not active

Feb 10, 2011 at 10:55 AM

Hi I create simpel MDI in caliburn micro something like this : http://devlicio.us/blogs/rob_eisenberg/archive/2010/10/19/caliburn-micro-soup-to-nuts-part-6c-simple-mdi-with-screen-collections.aspx.

App is something like chat window.

Every tab item is identified by ID (ID is DisplayName propety -> NickName).

Situation is that I have active some item, and user is chating.

Active is tab item with DisplayName User1.

It arrived new message from server, I would something create and show another tab item (DisplayName User2) in shell, but not as active.

I open new tab with this metod:

    public bool OpenChatTab(string id)
    {
        if (!ActiveTabItems.ContainsKey(id))
        {
            var w = IoC.Get<ITabChatViewModel>();
            w.Initialize(id);               
            w.DisplayName = id;

            ActivateItem(w);

            ActiveTabItems.Add(w.id,w);
            return true;
        }
        return false;
    }

Problem is method above create, add and active new tab item I need only create and add no activated.

Thank for advice.

Coordinator
Feb 10, 2011 at 1:37 PM

Just add the view model to the Items collection instead of calling ActivateItem.

Feb 10, 2011 at 6:11 PM

Thank, I am newbie in caliburn framework, it was scholar problem.

Thank for feedback Mr. Eisenberg