Windows phone 7 滑块控制行为更改

Windows phone 7 滑块控制行为更改,windows-phone-7,Windows Phone 7,我在wp7中创建了一个滑块来控制backgroundaudio播放器的音量 <Slider x:Name="VolumeSlider" Height="89" Margin="12,0,24,-20" VerticalAlignment="Bottom" ManipulationCompleted="OnSoundManipulationChanged" Maximum="100" SmallChange="1" LargeChange="100" Value="75"/> 发

我在wp7中创建了一个滑块来控制backgroundaudio播放器的音量

<Slider x:Name="VolumeSlider" Height="89" Margin="12,0,24,-20" VerticalAlignment="Bottom" ManipulationCompleted="OnSoundManipulationChanged" Maximum="100" SmallChange="1" LargeChange="100" Value="75"/>

发生的情况是,我试图操纵滑块,但滑块只移动了一小步,即使我尝试移动很长的距离。 直到我将手指从滑块上移开,操纵完成事件才被触发,但它也只是设置了较小的值更改

这种行为发生在我的应用程序中导航到另一个页面一次之后。
如果我重新启动应用程序,它会再次工作。

我找到了一个解决方案,该解决方案由Paul Sinnema发布,效果很好

}



using System.Windows;  
using System.Windows.Controls;  

namespace ControlClassLibrary  
{  
public class PSSlider : Slider  
{  
    public PSSlider()  
    {  
    }  

    public UIElement GestureListenerBug  
    {  
        get { return (UIElement)GetValue(GestureListenerBugProperty); }  
        set { SetValue(GestureListenerBugProperty, value); }  
    }  

    public static readonly DependencyProperty GestureListenerBugProperty =  
        DependencyProperty.Register("GestureListenerBug", typeof(UIElement), typeof(PSSlider), new PropertyMetadata(null));  

    protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)  
    {  
        SetHitTestVisibility(false);  

        base.OnMouseEnter(e);  
    }  

    protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)  
    {  
        SetHitTestVisibility(true);  

        base.OnMouseLeave(e);  
    }  

    private void SetHitTestVisibility(bool visible)  
    {  
        if (GestureListenerBug != null)  
        {  
            GestureListenerBug.IsHitTestVisible = visible;  
        }  
    }  
}  
<ct:PSPhoneApplicationPage x:Class="MCRemote.MainPage" 
                       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                       xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
                       xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
                       xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" 
                       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                       xmlns:cv="clr-namespace:MCRemote.Converters" 
                       xmlns:ct="clr-namespace:ControlClassLibrary;assembly=ControlClassLibrary" 
                       xmlns:co="clr-namespace:MCRemote.Controls" 
                       xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
                       mc:Ignorable="d" 
                       x:Name="Main" 
                       SupportedOrientations="Portrait" 
                       Orientation="Portrait" 
                       shell:SystemTray.IsVisible="True" 
                       Loaded="PhoneApplicationPageLoaded" 
                       d:DesignHeight="768" 
                       d:DesignWidth="480" 
                       Foreground="White">  
            <ct:PSSlider x:Name="VolumeSlider" 
                         GestureListenerBug="{Binding ElementName=Main}" 
                         Maximum="1" 
                         Minimum="0" 
                         SmallChange="0.01" 
                         LargeChange="0.1" 
                         ManipulationStarted="SliderManipulationStarted" 
                         ManipulationCompleted="SliderManipulationCompleted" 
                         Value="{Binding PlaybackInfo.BoundVolume, Mode=TwoWay}" 
                         Grid.Column="1" 
                         Grid.Row="2" />