Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6710789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:03:47+00:00 2026-05-26T08:03:47+00:00

Hi I user WPF/Calibur Micro/MEF. I I try have more active screen in shell.

  • 0

Hi I user WPF/Calibur Micro/MEF. I I try have more active screen in shell. First I define screens – User controls.

  1. Screen – View model
public interface IProjectsViewModel
{

}
[Export(typeof(IProjectsViewModel))]
public class ProjectsViewModel:Screen,
    IProjectsViewModel
{

}

2.Screen -View Model

public interface IProjectInfoViewModel
{

}

[Export(typeof(IProjectInfoViewModel))]
public class ProjectInfoViewModel :Screen, 
    IProjectInfoViewModel
{
    [Import]
    internal IMessageBox MsgBox { get; set; }

    public void BtnClick()
    {
        MsgBox.ShowInfo("Btn click",string.Empty);
    }
}

I second screen I have only one button if user click on the button it showed message box.

No most important part shell. Shell is WPF window.

View:

<Window x:Class="CaliburnSkelet.Views.ShellView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Views="clr-namespace:CaliburnSkelet.Views" 
        xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" 
        Title="ShellView" Height="300" Width="300">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <!--<ContentControl x:Name="Projects" Grid.Column="0"/>
        <ContentControl x:Name="ProjectInfo" Grid.Column="1"/>-->
        <Views:ProjectsView  cal:View.Model="{Binding Projects}" 
                             Grid.Column="0"/>
        <Views:ProjectInfoView cal:View.Model="{Binding ProjectInfo}"
                               Grid.Column="1"/>
    </Grid>
</Window>

ShellViewModel:

public interface IShellViewModel :IScreen
{
    ProjectInfoViewModel ProjectInfo { get; set; }
    ProjectsViewModel Project { get; set; }
}

[Export(typeof(IShellViewModel))]
public class ShellViewModel:Conductor<IScreen>.Collection.AllActive,
    IShellViewModel, IPartImportsSatisfiedNotification

{
    [Import]
    public ProjectInfoViewModel ProjectInfo { get; set; }

    [Import]
    public ProjectsViewModel Project { get; set; }

    public void OnImportsSatisfied()
    {
    }
}

If I try compile this code I get error:

Could not locate any instances of contract
CaliburnSkelet.ViewModels.IShellViewModel.

StackTrace:

  at CaliburnSkelet.BootStraper.MefBootStrapper.GetInstance(Type serviceType, String key) in E:\C# PROJECTS\CaliburnSkelet\CaliburnSkelet\BootStraper\MefBootStrapper.cs:line 69
   at Caliburn.Micro.Bootstrapper.DisplayRootViewFor(Type viewModelType)
   at Caliburn.Micro.Bootstrapper`1.OnStartup(Object sender, StartupEventArgs e)
   at System.Windows.Application.OnStartup(StartupEventArgs e)
   at System.Windows.Application.<.ctor>b__1(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

I tried make a test and change properties shell view model class.

[Export(typeof(IShellViewModel))]
public class ShellViewModel:Conductor<IScreen>.Collection.AllActive,
    IShellViewModel, IPartImportsSatisfiedNotification

{
    //[Import]
    public ProjectInfoViewModel ProjectInfo { get; set; }

    //[Import]
    public ProjectsViewModel Project { get; set; }

    public void OnImportsSatisfied()
    {
        ProjectInfo=new ProjectInfoViewModel();
        Project=new ProjectsViewModel();
    }
}

I don’t import view models classes to shell view model with MEF but I create new instances in method OnImportsSatisfied.

Application run but if I click on button variable MsgBox is null.

Code from ProjectInfoViewModel class:

        [Import]
        internal IMessageBox MsgBox { get; set; }

        public void BtnClick()
        {
//MsgBox is null
            MsgBox.ShowInfo("Btn click",string.Empty);
        }

Where can be problem?

here? Conductor.Collection.AllActive

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:03:48+00:00Added an answer on May 26, 2026 at 8:03 am

    On your ShellViewModel type, the ProjectInfo and Project properties should be of type IProjectInfoViewModel and IProjectsViewModel, as these are the types you have exported, and you should be working against those interfaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this custom wpf user control: ShowCustomer.xaml: <UserControl x:Class=TestControlUpdate2343.Controls.ShowCustomer xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml> <Grid> <TextBlock
I have a window (Windows form ) where i have two WPF user controls
I hope this makes sense. I have created several WPF User Controls. The lowest
There are a WPF User Control library and two (or more) User Controls in
I have a WPF Canvas and there are 3 WPF user controls on it.
In one of my WPF user controls I have a check box. If the
When hosting WPF user controls within a WinForms MDI app there is a drawing
I have a WPF user control with a number of textboxes, this is hosted
I have a wpf user control which exposes an IEnumerable ItemsSource DependencyProperty. I bind
I have a WPF User control that binds to a DataTable and generates CheckBox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.