开发者

MEF property export doesn't work after property value was changed

I face a 开发者_JS百科problem with exporting a property .

I have two view model :

public class ViewModelA
{
  [Export]
  public LanguageObj LObj { get; set; }
}

public class ViewModelB
{
  [Import]
  public LanguageObj LObj { get; set; }
}

when I run the my app , the first wire between the properties is made , but at first the languageObj is null , because the user didn't select language yet . when the user select language , the property in vm A is updated , but when I try toi get it in vm B still see the null value which mean mef didn't notified about this change .

Btw , if I use propert of type ObservableCollection for example , I really see the change, which mean each change on the collection in A I see it in B.

I moved to use method export , and its working fine , but really interesting why I cann't use the property export style .

I used :

[Export(typeof(Func<LanguageObj>))]
public LanguageObj GetLanguageObj()
{
  return LObj
}

and in VM B I use :

[Import]
public Func<LanguageObj>> LObj {get;set;}

Any ideas.

Thanks in advance ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜