事件序列化 [英] Serialization of Events

查看:122
本文介绍了事件序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在MVVM之后的应用程序上工作,有很多属性直接绑定到模型层(例如-Binding ="ViewModelProperty.ModelProperty.Text")

当我尝试保存业务对象时,抛出以下错误:

程序集``WindowsBase,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35''中的类型``System.ComponentModel.PropertyChangedEventManager''未标记为可序列化.

我了解可能很少有(INotify)事件订阅,而该对象不允许其进行序列化.

我无法使用[field:NonSerialized],因为我们有第三方DLL(我们无法访问代码).

有人遇到过这种情况吗?如果是这样,您如何摆脱它?

谢谢.

Mudit

Hi all

I am working on a application following MVVM, there are lot of properties directly binded to the model layer( like - Binding ="ViewModelProperty.ModelProperty.Text" )

when i try to save the business object the following error is thrown:

Type ''System.ComponentModel.PropertyChangedEventManager'' in Assembly ''WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'' is not marked as serializable.

I understand that there might be few (INotify)event subscriptions with the object which wont allow it to serialize.

I cant use [field:NonSerialized] as we have a third party DLL(we dont have access to the code).

Has anyone faced this type of scenario ever? if so how did you get rid of it ?

thanks.

Mudit

推荐答案

如果直接绑定到模型,则不会遵循MVVM.就这么简单.视图应该不了解模型-这就是ViewModel的用途.如果要监视更改并通过更改,请查看Josh Smith的
If you are binding directly to the model you aren''t following MVVM. It''s as simple as that. The view should have no knowledge of the Model - that''s what the ViewModel is for. If you want to monitor changes and pass them through, take a look at Josh Smith''s PropertyObserver[^].

I don''t know where your business object comes from - that seems to be randomly introduced into your question. When you are binding in MVVM, you don''t really need to worry about serialisation.


这篇关于事件序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆