开发者

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

开发者 https://www.devze.com 2023-04-13 04:42 出处:网络
I face a 开发者_JS百科problem with exporting a property . I have two view model : public class ViewModelA

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

精彩评论

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

关注公众号