WPF MVVM滑块Thumb事件未绑定

时间:2018-08-28 08:17:57

标签: c# wpf mvvm triggers slider

当尝试绑定Thumb事件(例如下面的XAML的DragStarted和DragCompleted)时,绑定根本无法正常工作。

XAML:

            <Slider TickFrequency="5" Orientation="Horizontal" Minimum="0" Maximum="1" Name="MediaSlider"
                Value="{Binding CurrentPosition}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Thumb.DragStarted">
                    <i:InvokeCommandAction Command="{Binding SliderDragStartedCommand}" CommandParameter="{Binding ElementName=MediaSlider}"/>
                </i:EventTrigger>
                <i:EventTrigger EventName="Thumb.DragCompleted">
                    <i:InvokeCommandAction Command="{Binding SliderDragCompletedCommand}" CommandParameter="{Binding ElementName=MediaSlider}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Slider>

型号:

        public void SliderDragStarted()
    {
        DragStarted = true;
    }

    public void SliderDragCompleted(Slider slider)
    {
        DragStarted = false;
        MediaPlayer.Position = (float)slider.Value;
    }

如何将Thumb事件绑定到滑块? 谢谢!

0 个答案:

没有答案