c# - WPF slider thumb.DragCompleted

标签 c# wpf naudio

我正在学习 NAudio 的 Mark Heath 类(class)。 我在事件中使用 slider :

Thumb.DragCompleted="SilderPositionOnDragCompleted"

在 C# 中:

private void SilderPositionOnDragCompleted(object sender, System.Windows.Controls.Primitives.Thumb.DragCompleted e)
    {
            if (reader != null)
            {
                reader.CurrentTime = TimeSpan.FromSeconds(slider.Value);
            }
    }

我很确定我写错了:

System.Windows.Controls.Primitives.Thumb.DragCompleted 

因为我不知道我需要在那里写什么 - 我在网站上看到了这个。

错误是: Here

我需要做什么?

谢谢!

最佳答案

试试这个:

private void SilderPositionOnDragCompleted(object sender, RoutedEventArgs e)
{
    if (reader != null)
    {
        reader.CurrentTime = TimeSpan.FromSeconds(slider.Value);
    }
}

第二个参数的类型应为 RoatedEventArgs

如果您以编程方式连接事件处理程序,则应使用以下语法:

Thumb.DragCompleted += SilderPositionOnDragCompleted;

...其中“Thumb”是您拇指的名称:

<Thumb x:Name="Thumb" />

或者

Thumb Thumb = ...;

关于c# - WPF slider thumb.DragCompleted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42029017/

相关文章:

c# - WPF:动画线减慢 UI

WPF ItemsControl : restrict the type of the item to a specific one

C# asp.net MySQL 值返回为 Null

c# - CKEditor 在 asp :textbox 上有空值

c# - 在 WIN 7 旗舰版中与来自 c++ 的数字签名 c# com dll 通信的问题

c# - Naudio-将音频流放入值[-1,1]

c# - wma压缩音频文件使用Naudio抛出错误

c# - 使用 C# WebBrowser 插入 CSS

c# - CruiseControl.NET (CCNET) "Process exited event received"但构建等待?

c# - 听WaveOutDevice