我将Slider的值绑定到表示联网设备上的音量的整数属性。这个网络请求需要一点时间(通常小于 100 毫秒),并且不知何故会导致 Slider 感觉不稳定。
这是我过于简化的代码来澄清:
Private _playbackVolume As Integer
Private _deviceForDemonstrationPurposes As New Device
Public Property PlaybackVolume As Integer
Get
Return _playbackVolume
End Get
Set(value As Integer)
_deviceForDemonstrationPurposes.Volume = value
End Set
End Property
Friend Sub UpdateVolume(volume As Integer)
' this is called by the instance of Device whenever its volume changes.
_playbackVolume = volume
RaisePropertyChanged("PlaybackVolume") ' INotifyPropertyChanged implementation.
End Sub
绑定到PlaybackVolume
属性将导致 setter 在仍然拖动拇指时触发。由于网络延迟问题,无论请求完成多少毫秒,滑块都会被锁定。
什么被认为是使滑块再次变得光滑的最佳方法?