Where Should IScrollInfo be Implemented: View or ViewModel?
I need to implement the IScrollIn开发者_开发技巧fo interface, which is a beast from what I have read. But I am struggling with where it should be implemented.
I think it should be in the View because there's a reference to Visual in the MakeVisible method. In addition, the ScrollViewer will look for the IScrollInfo interface when you set the CanContentScroll="True". This means that the Custom Panel that arranges my objects will need to inherit the ViewModel or wrap the ViewModel in the view by calling the VM's implementation.
So am I wrong, is it supposed to be in the ViewModel?
I see IScrollInfo as pure View. It represents a "scrollable region" - which has no meaning outside of a particular View. There is no business logic involved in a "scrollable region", and, as such, it should be kept out of the ViewModel entirely.
You implement IScrollInfo on a custom Panel. As such it is view specific. There is a twist however. Because of the lookless model for WPF controls, the control itself is a viewmodel of sorts.
精彩评论