Mvvmcross Android的 - 视图模型人口中旋转片段视图 [英] Mvvmcross Android - Rotating fragment view during viewmodel population

查看:167
本文介绍了Mvvmcross Android的 - 视图模型人口中旋转片段视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,当我试图同时转动手动重新水合物片段的ViewModels。一切似乎当我旋转片段一旦我的视图模型已被填充做工精细,我要做的就是:

I'm having a problem when I try to manually re hydrate fragment viewmodels while rotating. Everything seems to work fine when I rotate a fragment once my viewmodel has been populated, all I do is :

this.viewmodel = foo的

this.viewmodel = foo

但如果我尝试的人口(例如从Web服务)期间旋转片断,然后重新连接存储视图模型人口已经完成了之前的观点似乎并不正确地绑定。

but if I try to rotate the fragment during population (e.g. from a web service) and then re-attach the stored viewmodel before population has completed the view doesn't appear to bind properly.

我知道有一个缺乏源(在这个职位),但我不知道这是否在原则上工作,如果有固定的绑定问题的方式(具有约束力的环境等也尽管存在),如果这是真的这个问题?

I know there is a lack of source (in this post) but I was wondering whether this should work in principle and if there was a way to fix the binding issue (a binding context etc does exist though) if that is indeed the issue?

如果我以后人口再次旋转片段视图填充为正常。

if I rotate the fragment again after population the view populates as normal.

推荐答案

一个解决这个问题的方法是指示Android不重新创建活动的配置更改时。请确保您有在活动属性specificedConfigurationChanges,你重写OnConfigurationChanged。

One way to approach this problem is to instruct Android not to re-create the activity when configuration changes. Make sure you have "ConfigurationChanges" specificed in the activity attribute and you override OnConfigurationChanged.


    [Activity(
        Label = "Sample",
        ConfigurationChanges = global::Android.Content.PM.ConfigChanges.Orientation | global::Android.Content.PM.ConfigChanges.ScreenSize | global::Android.Content.PM.ConfigChanges.KeyboardHidden
        )]
    public class SampleActivity : MvxFragmentActivity
    {
        //...

        public override void OnConfigurationChanged(global::Android.Content.Res.Configuration newConfig)
        {
            base.OnConfigurationChanged(newConfig);
        }
    }

这篇关于Mvvmcross Android的 - 视图模型人口中旋转片段视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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