我应该首先说我对 MVVM 模式比较陌生。话虽如此,我有两个选项卡正在尝试加载大型数据集。我希望在加载页面时加载第一个选项卡,但是当您单击另一个选项卡时,第一个选项卡将被卸载,第二个选项卡将被加载(也称为延迟加载)。关于如何做到这一点的任何想法?
问问题
741 次
2 回答
2
It's important to keep the UI responsive to the user and loading large amounts of data can have a negative effect on that experience. That's why in situations like yours I have the view-model call a method that uses a BackgroundWorker(s) to load the data. The earlier you do this in the app's lifecycle, the better your user's experience.
So, like mathieu suggested, bind the control's property to your view-model and have your view-model load the data in a non-blocking fashion.
于 2012-09-10T13:37:12.870 回答
0
您可以将 TabControl 的 SelectedValue 属性绑定到视图模型的属性。
这样,您可以在属性值更改时卸载/加载正确的数据。
于 2012-09-10T13:12:07.410 回答