0
當我讀到這一行時:有沒有模型可以有一個視圖和viewmodel?
viewmodel不僅暴露模型,還暴露其他屬性(例如狀態信息,如「忙」指示符)和命令。
http://www.codeproject.com/Articles/100175/Model-View-ViewModel-MVVM-Explained
我想知道在視圖當前設置是否應被視爲國家的視圖或部分的財產,並放置在一個視圖模型。
例如我目前有一個偏好窗口綁定到一個視圖模型,包含當前的顏色和一堆綁定到視圖模型的顏色選擇器。然後命令取消更改並重新應用舊設置,如果單擊確定或取消。
當前顏色應該是視圖上的屬性,還是當前位置正確?
public class PreferencesWindowViewModel:DependencyObject
{
private DelegateCommand updatePreferencesCommand;
public ICommand UpdatePreferencesCommand
{
get { return updatePreferencesCommand; }
}
private DelegateCommand cancelCommand;
public ICommand CancelCommand
{
get { return cancelCommand; }
}
public Color HighValuePenColor
{
get { return (Color)GetValue(HighValuePenColorProperty); }
set
{
SetValue(HighValuePenColorProperty, value);
}
}
[不要使用視圖模型的DependencyObjects](http://kentb.blogspot.com.ar/2009/03/view-models-pocos-versus.html) –
是啊我注意到最近一邊查看討論依賴對象vs inotifypropertychanged的文章。儘管如此,我還沒有回去改變他們 –