Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 是否可以将属性设置器作为委托传递?_Vb.net - Fatal编程技术网

Vb.net 是否可以将属性设置器作为委托传递?

Vb.net 是否可以将属性设置器作为委托传递?,vb.net,Vb.net,我为快速简单的UI动画制作了这个函数 Delegate Sub AnimateDoubleSetter(value As Double) Sub AnimateDouble(Setter As AnimateDoubleSetter, [From] As Double, [To] As Double, DurationMs As Double) Dim t As New System.Windows.Threading.DispatcherTimer With {.Interval =

我为快速简单的UI动画制作了这个函数

Delegate Sub AnimateDoubleSetter(value As Double)
Sub AnimateDouble(Setter As AnimateDoubleSetter, [From] As Double, [To] As Double, DurationMs As Double)
    Dim t As New System.Windows.Threading.DispatcherTimer With {.Interval = New TimeSpan(400000)}
    Dim StartTime = DateTime.Now
    Dim Diff = [To] - [From]

    AddHandler t.Tick, Sub()
                           Dim ms = (DateTime.Now - StartTime).TotalMilliseconds
                           Dim fraction = Math.Min(ms / DurationMs, 1)
                           If fraction = 1 Then t.Stop()
                           Setter([From] + Diff * fraction)
                       End Sub
    t.Start()
End Sub
我是这样用的

AnimateDouble(Sub(x As Double) cBackground.Opacity = x, 0, 0.3, 200)

但我突然想到,既然cBackground.Opacity是一个属性,它已经是一对由getter/setter组成的函数了。是否可以从属性中提取setter函数,以便我可以传递该函数,或者甚至传递属性本身?

我猜您希望用更短的东西替换
Sub(x为双精度)cBackground.Opacity=x
?我猜您希望用它替换
Sub(x为双精度)cBackground.Opacity=x
是否使用较短的字体?