我需要在我的ViewModel中订阅我的某个模型的INotifyPropertyChanged
。我的研究让我:How do I update the parent viewmodel when child viewmodel is updated。
我尝试按照#3中的建议使用WeakSubscribe
,但在进入和离开视图几次后,我的整个应用程序会冻结或崩溃。
以下是我在ViewModel中的Init()
代码:
foreach (var sale in Model.Sales)
{
sale.WeakSubscribe(delegate
{
Model.CalculateSalesTotals();
});
}
当应用崩溃时,我收到SIGSEGV
:
I/mono-stdout(30334): mvx:Diagnostic:227.00 Showing ViewModel InvoiceAuthorizationViewModel I/ActivityManager( 391): START u0 {flg=0x10000000 cmp=com.desco.escMobile/escmobile.android.views.InvoiceAuthorizationView (has extras)} from pid 30334 I/mono-stdout(30334): mvx:Diagnostic:227.19 Loading new ViewModel from Intent with Extras D/dalvikvm(30334): GC_EXPLICIT freed 783K, 5% free 17252K/18068K, paused 2ms+8ms, total 53ms I/mono-stdout(30334): MvxBind:Warning:227.59 Unable to bind: source property source not found Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPr opertyNamePropertyToken on null-object I/mono-stdout(30334): MvxBind:Warning:227.61 Unable to bind: source property source not found Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPr opertyNamePropertyToken on null-object I/mono-stdout(30334): MvxBind:Warning:227.63 Unable to bind: source property source not found Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPr opertyNamePropertyToken on null-object I/dalvikvm(30334): Jit: resizing JitTable from 4096 to 8192 I/ActivityManager( 391): Displayed com.desco.escMobile/escmobile.android.views.InvoiceAuthorizationView: +755ms (total +1s259ms) I/ActivityManager( 391): Displayed com.desco.escMobile/escmobile.android.views.InvoiceAuthorizationView: +1s279ms I/ActivityManager( 391): Process com.android.vending (pid 30179) has died. E/mono-rt (30334): Stacktrace: E/mono-rt (30334): E/mono-rt (30334): E/mono-rt (30334): ================================================================= E/mono-rt (30334): Got a SIGSEGV while executing native code. This usually indicates E/mono-rt (30334): a fatal error in the mono runtime or one of the native libraries E/mono-rt (30334): used by your application. E/mono-rt (30334): ================================================================= E/mono-rt (30334): I/ActivityManager( 391): Process com.desco.escMobile (pid 30334) has died. I/WindowState( 391): WIN DEATH: Window{42cf2e60 u0 com.desco.escMobile/escmobile.android.views.InvoiceAuthorizationView} W/ActivityManager( 391): Force removing ActivityRecord{42e05b20 u0 com.desco.escMobile/escmobile.android.views.InvoiceAuthorizationView}: app died, no saved st ate I/WindowState( 391): WIN DEATH: Window{427bfbf0 u0 com.desco.escMobile/escmobile.android.views.DispatchListView} I/WindowState( 391): WIN DEATH: Window{42b32b50 u0 com.desco.escMobile/escmobile.android.views.InvoiceDetailsView} I/WindowState( 391): WIN DEATH: Window{43003e48 u0 com.desco.escMobile/escmobile.android.views.InvoiceAuthorizationView} I/WindowState( 391): WIN DEATH: Window{42aea920 u0 com.desco.escMobile/escmobile.android.views.DispatchDetailsView} D/dalvikvm(30434): Late-enabling CheckJNI I/ActivityManager( 391): Start proc com.desco.escMobile for activity com.desco.escMobile/escmobile.android.views.InvoiceAuthorizationView: pid=30434 uid=10086 gids={50086, 3003, 1015, 1028} D/Zygote ( 129): Process 30334 exited cleanly (255)
有什么建议吗?