Caliburn.Micro and Infragistics XamMenu

Topics: Bugs
Jun 14, 2012 at 2:17 PM

I just started a new project in WPF using Caliburn.Micro. I'm using Infragistics NetAdvantage version 11 GUI components. I started with the basic sample project, added a File menu with Open and Exit sub menus. I gave these menu items names as such: Open, Exit. I added the methods (Open and Exit) in the ViewModel. My Open method simply invokes the OpenFileDialog.

However, when the application is run, the first menu item is being fired automatically, meaning the OpenFileDialog is run without clicking File->Open. The main window is loaded, and the OpenFileDialog is shown.

I changed the menu system to use the standard WPF menu and menu items, and everything works as expected.

Any ideas? Anyone using Infragistics GUI components with Caliburn.Micro successfully.


Jun 14, 2012 at 2:54 PM

It seems that the Loaded event on a MenuItem is used to trigger an action. Are you suing a custom convention? Without a bit of code, this is the best I can say.

Jun 14, 2012 at 3:05 PM

Thanks for the timely response.

No custom convention used.

Following is the XAML from ShellView.xaml:

<ig:XamMenu Grid.Row="0" Height="20" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="MenuMain" VerticalAlignment="Top" Width="Auto" >
            <ig:XamMenuItem Name="MenuItemFile" Header="File">
                <ig:XamMenuItem Name="MenuItemFileOpen" Header="Open"/>
                <ig:XamMenuItem Name="MenuItemFileExit" Header="Exit"/>
            <ig:XamMenuItem Name="MenuItemView" Header="View"/>
            <ig:XamMenuItem Name="MenuItemTools" Header="Tools">
                <ig:XamMenuItem Name="MenuItemToolsPreferences" Header="Preferences"/>
            <ig:XamMenuItem Name="MenuItemHelp" Header="_Help">
                <ig:XamMenuItem Name="MenuItemHelpAbout" Header="About"/>
Following is the full C# code from ShellViewModel.cs
using System;
using System.Windows.Forms;
using System.Collections.ObjectModel;
using Caliburn.Micro;
using System.ComponentModel.Composition;

namespace UT.PipeFlow.ViewModels
    public class ShellViewModel : Conductor<IScreen>.Collection.OneActive
        private string title;
        public string Title
            get { return title; }
            set { title = value; NotifyOfPropertyChange(() => Title); }
        private string currentStatus = "Ready";
        public string CurrentStatus
            get { return currentStatus; }
            set { currentStatus = value; NotifyOfPropertyChange(() => CurrentStatus); }

        public ShellViewModel()
            Title = "UT Pipe Flow";

        public void MenuItemFileExit()

        public void MenuItemFileOpen()
            using (OpenFileDialog ofd = new OpenFileDialog())
                if (ofd.ShowDialog() == DialogResult.OK)
Jun 14, 2012 at 3:20 PM

It seems that the XamMenuItem convention uses the Loaded event to trigger the action.

If you are using a special convention for such item, you need to change the default event to Click or an equivalent event. Otherwise, if no convention is used, then the XamMenuItem picks a convention which is not correct, and you need to create a custom convention to define the proper default event.