更改属性值后,MEF 属性导出不起作用
我在出口财产时遇到问题。
我有两个视图模型:
public class ViewModelA
{
[Export]
public LanguageObj LObj { get; set; }
}
public class ViewModelB
{
[Import]
public LanguageObj LObj { get; set; }
}
当我运行我的应用程序时,会在属性之间建立第一条连线,但首先 languageObj 为 null,因为用户尚未选择语言。当用户选择语言时,vm A 中的属性会更新,但是当我尝试在 vm B 中获取它时,仍然看到 null 值,这意味着 mef 没有通知此更改。
顺便说一句,例如,如果我使用 ObservableCollection 类型的属性,我确实看到了变化,这意味着 AI 中集合的每个变化都会在 B 中看到它。
我转而使用方法导出,它工作正常,但很有趣为什么我不能不使用属性导出样式。
我使用:
[Export(typeof(Func<LanguageObj>))]
public LanguageObj GetLanguageObj()
{
return LObj
}
和在 VM BI 中使用:
[Import]
public Func<LanguageObj>> LObj {get;set;}
任何想法。
提前致谢 ...
I face a 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 ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论