阅读背景:

当创建新的ViewModel实例MVVM时,视图状态保持不变

来源:互联网 

I'm sure the answer to this is already out there just can't seem to find it. I have a SubView which I am dynamically in the the MainViewModel. This is then displayed to the user using a style. When I create a new instance of the SubViewModel the View is not recreated if it of the same type as it was before. This is an issue as the selected tab remains the same and is not reset to the first tab. Although I could just save the selected tab index in the ViewModel to reset it I feel it is purely View state and should not exist in the ViewModel. I assume this is the styling not noticing that the instance has changed. Is there anyway to force the View to create a new instance every time the ViewModel changes?I'm sure the answer to this is already out ther




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: