Binding a WPF read only view to a viewmodel
I have a WPF application designed using MVVM. I have a view which will always be read only. It is a product result view. So a user will searh for a product in someother view and the search result will be displayed. So when the user double clicks a particular result record, the product details view will be opened which is a read only view. When the user double click another product record in the search result, the sam product details view will be refreshed(Not instantiated) with the new details data. I am thinking of binding the product details view to the viewmodel using OneWayToSource binding mode. Is this good?I believe this will result in reduced memory footprint.Pls confirm? Also, still, do i have to implement INotifyPropertyChanged in the viewmodel properties even the view is a readonly view?
I doubt the binding mode will make any difference to memory footprint, just extra stuff to type in. So long as you use read-only controls and textblocks and the like then keep it simple.
As for the NotifyPropertyChanged: No, it isn't required. However, if you have an Edit view sharing the same view model then it can be beneficial since then edits to those properties will automatically propogate to an open read-only view. Same goes if there are any commands or such that may result in a value of the viewmodel changing, without INotifyPropertyChanged, the view will not refresh those changes. If those types of refreshes aren't needed, then neither is INotifyPropertyChanged.
链接地址: http://www.djcxy.com/p/50470.html上一篇: 在DataContext更改时将DependencyProperty推回到ViewModel
下一篇: 将WPF只读视图绑定到视图模型