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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:06:45+00:00 2026-05-18T11:06:45+00:00

I have a need of one DependencyProperty from a View in my ViewModel constructor:

  • 0

I have a need of one DependencyProperty from a View in my ViewModel constructor:

My problem: MEF wouldn’t SatisfyImports() ‘because it is marked with one or more ExportAttributes’ (that is the exception)

This is the code structure for the VIEW:

public class MyView : UserControl
{
    [Export(MethodTypes.ChartType)]
    public Charts MyChartType
    {
        get
        {
            object k = GetValue(ChartTypeProperty);
            Charts f = (Charts)Enum.Parse(typeof(Charts), k.ToString(), true);
            return f;
        }
        set
        {
            SetValue(ChartTypeProperty, value);
        }
    }

    [Import(ViewModelTypes.GenericChartViewModel)]
    public object ViewModel
    {
        set
        {
            DataContext = value;
        }
    }

    public MyView()
    {
        InitializeComponent();

        if (!ViewModelBase.IsInDesignModeStatic)
        {
            // Use MEF To load the View Model
            CompositionInitializer.SatisfyImports(this);
        }
    }
}

and the VIEWMODEL:

[PartCreationPolicy(CreationPolicy.NonShared)]
[Export(ViewModelTypes.GenericChartViewModel)]
public class GenericChartViewModel
{
    [ImportingConstructor]
    public GenericChartViewModel([Import(MethodTypes.ChartType)] Charts forChartType)
    {
        string test = forChartType.ToString();
    }
}

Please give me any hints on this or maybe suggest a better solution for passing parameters through mef

In my case, I would need to pass only dependecyproperty’s for now…

Thanks

  • 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-18T11:06:45+00:00Added an answer on May 18, 2026 at 11:06 am

    Your work around isn’t really good.. can’t you remove the export from ChartTypes and pass it manually to whoever wants it? I presume the viewmodel is only one insterested in it..

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

Sidebar

Related Questions

i need one more thing i have function show_image() { document.write(<img src=+this.link+ ,alt=+this.alt+ ,width=600,
I have a WizardStep Control from which i need one information: The total amount
I have a Flex button. I need one color on the left and another
Someone have any sample of Comet app .net? I need one sample how to
I need to have one column as the primary key and another to auto
i need to have one project on asp.net mvc 1 but i want to
Related to https://stackoverflow.com/questions/139944/where-can-one-find-free-software-icons-images I have a need for free weather-related icons. Specifically, I need
I need to have two UITableViews on one UIView. I can make it work
I need to have MySQL query like this one: UPDATE table_name SET 1 =
I need to have a grid on one of my webpages that will be

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.