mvvm - Silverlight View exporting DependencyProperty to ViewModel via MEF -


i have need of 1 dependencyproperty view in viewmodel constructor:

my problem: mef wouldn't satisfyimports() 'because marked 1 or more exportattributes' (that exception)

this code structure view:

public class myview : usercontrol {     [export(methodtypes.charttype)]     public charts mycharttype     {                 {             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 load view model             compositioninitializer.satisfyimports(this);         }     } } 

and 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 hints on or maybe suggest better solution passing parameters through mef

in case, need pass dependecyproperty's now...

thanks

your work around isn't good.. can't remove export charttypes , pass manually whoever wants it? presume viewmodel 1 insterested in it..


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -