1

I have a quick (hopefully) question on how to implement a composite field using MVVM.

I have 2 examples, one is on the sql end I am storing gps coordinates in the following manner "Latitude,Longitude" for instance "45.55555,-80.00000". the other example is storing feet and inches as a single double field with it being ft.in.

How should I go about this? Should I have two fields and in the model or Viewmodel composite them if the other piece exists? Should I bind them to the same field and somehow validate the sets?

thanks!

4

1 回答 1

1

在模型中,我通常使用最接近/最接近源的结构/布局,因此可以轻松/快速地读取和写入。

在 ViewModel 中,我的目标是表示 View 以适应绑定。

一般来说,我让 ViewModel 负责 Model 和 ViewModel 之间的转换。

所以 ViewModel 和 Model 的一个属性是否应该有一个或两个字段取决于 View 和 Source 的要求。

于 2013-06-14T05:35:25.517 回答