Issue with MVVMLight ViewModelBase public parameterless constructor in inherited base class for WP7 Tombstoning

前端 未结 1 365
刺人心
刺人心 2021-01-21 01:47

I am handling tombstoning in Wp7 by dumping my ViewModel into the PhoneApplicationService state (see this link for more info).

My ViewModel (VM) inherits from the MVVM L

1条回答
  •  借酒劲吻你
    2021-01-21 02:26

    Public default constructors in abstract classes are frowned upon by StyleCop, which is why I made the ViewModelBase one protected. As you found out, this however causes issues with serialization. This issue is more acute in WP7 where it is tempting to dump the whole vm in serialization for safe keeping.

    Right now, the only fix I can propose is to implement your own viewmodelbase class. I will consider changing the constructor to public in a future release.

    Cheers, Laurent

    0 讨论(0)
提交回复
热议问题