2012-07-09 6 views
0

wp7에서 배경 오디오 플레이어의 볼륨을 제어하는 ​​슬라이더를 만들었습니다.슬라이더 컨트롤 동작 변경

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

나는 무엇보다 슬라이더를 조작하려고하는데, 장거리 이동하려고해도 슬라이더가 단지 작은 단계로 이동합니다. 슬라이더에서 손가락을 뗄 때까지 ManipulationCompleted 이벤트가 발생하지 않지만 작은 값 변경도 설정됩니다.

이 문제는 내 앱의 다른 페이지로 한 번 이동 한 후에 발생합니다. 앱을 다시 시작하면 다시 작동합니다.

답변

0

해결책은 Paul Sinnema가 게시했으며 문제가 해결되었습니다. }

<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"> 

http://forums.create.msdn.com/forums/p/82897/501068.aspx

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: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" />