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 8315785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:12:40+00:00 2026-06-08T21:12:40+00:00

I have a WPF application in PRISM architecture. I have a user-control (view) that

  • 0

I have a WPF application in PRISM architecture.

I have a user-control (view) that has 2 user-controls inside it.

Here is the idea :
Here is an idea :

The reason why the ‘Search user-control’ is in its own user-control, is because I plan on reusing it in my application.

The main user-control (black) is called ‘MainView’ and has 2 user-controls in it:
– A user-control that has several textbox control I can filter by, and a ‘Search’ button
– A user-control that has a grid where I display the results

Each of these user-controls (and the parent, “Main View”) are ‘Views’ and have ‘View-Models’.

Everything is shown fine, except for the fact that the ‘child’ user-controls do not create their own ‘View-Models’ automatically.

In the view-model’s classes I have the ‘Export’ attribute,
and in the View’s code-behind I have this snippet:

[Import]
FilterFieldsViewModel ViewModel
{           
    set
    {
       this.DataContext = value;
    }
}

Setting the ‘View-Model’ does happen for the ‘Main View’, but not for the child views…

I have a command binded to the ‘Search’ button of the ‘Search User-control’,
and when the application loads – I get an error in the output window, saying :

BindingExpression path error: ‘SearchCommand’ property not found on ‘object’ ”MainWindowViewModel’ (HashCode=22047425)’. BindingExpression:Path=SearchCommand; DataItem=’MainWindowViewModel’ (HashCode=22047425); target element is ‘Button’ (Name=’Search’); target property is ‘Command’ (type ‘ICommand’)

For some reason the command from the ‘child’ user-control tries to bind to the view-model in the main window’s view model, because for some reason – the child user-control’s view model is not instantiated.

Why is this ?

  • 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-06-08T21:12:42+00:00Added an answer on June 8, 2026 at 9:12 pm

    Your dependency injection container (MEF) is not registering imports on the sub-views, because they are created by the MainView and not by MEF. What you probably want to do is create a property on your MainViewModel:

    [Import]
    public FilterFieldsViewModel FilterFieldsViewModel {get; set; }
    

    Then in XAML:

    <UserControl ....>
       ...
       <SearchUserControl DataContext="{Binding FilterFieldsViewModel}" ... />
       ...
    </UserControl>
    

    This enables MEF to create an instance of FilterFieldsViewModel for you and sends it down to the SearchUserControl.

    This is the basic concept of course, maybe you would want to create a ‘SearchViewModelBase‘ or something that has the FilterFieldsViewModel.

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

Sidebar

Related Questions

I have a WPF application that is written using MVVM Prism. It has a
I have WPF Application where I have One main form and other user controls
I have a WPF application based on PRISM that utilizes the MVVM pattern. I
I'm developing a WPF/PRISM based application. The parent view(usercontrol) has many regions in it
I have a WPF windows application that uses the ms ribbon control for the
I have WPF application that has a login form. I would like to make
I have started to build a WPF application in MVVM architecture (using Prism infrastructure).
I have a WPF Desktop application using Prism 4, in my bootstrapper i have
This relates to Composite Application Guidance for WPF, or Prism. I have one MainRegion
I have WPF C# application that communicate with a PLC (i.e. write/read Omron PLC's

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.