回答

0

您可以自定義滑動器滾動條來工作。獲取列表框中元素的總數,然後根據您選擇的條目索引操作滾動條的值。

<Style x:Key="backgroundSliderAlpha" TargetType="Slider"> 
     <Setter Property="BorderThickness" Value="0"/> 
     <Setter Property="BorderBrush" Value="Transparent"/> 
     <Setter Property="Maximum" Value="10"/> 
     <Setter Property="Minimum" Value="0"/> 
     <Setter Property="Value" Value="0"/> 
     <Setter Property="Background" Value="{StaticResource PhoneChromeBrush}"/> 
     <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="Slider"> 
        <Grid Width="30"> 
         <Grid.Background> 
          <SolidColorBrush Color="{StaticResource PhoneBorderColor}"/> 
         </Grid.Background> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Normal"/> 
           <VisualState x:Name="MouseOver"/> 
           <VisualState x:Name="Disabled"> 
            <Storyboard> 
             <DoubleAnimation Duration="0" To="0.1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HorizontalTrack"/> 
             <DoubleAnimation Duration="0" To="0.1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="VerticalTrack"/> 
            </Storyboard> 
           </VisualState> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 

         <Grid x:Name="VerticalTemplate" Margin="{StaticResource PhoneVerticalMargin}"> 
          <Rectangle x:Name="VerticalTrack" IsHitTestVisible="False" Margin="8,0,8,0" Width="12" Fill="#FF487257" RadiusX="5" RadiusY="5"/> 
          <Rectangle x:Name="VerticalFill" IsHitTestVisible="False" Margin="8,0,8,0" Width="12" Fill="#FF487256" RadiusX="5" RadiusY="5"> 
           <Rectangle.Clip> 
            <RectangleGeometry Rect="0, 0, 2, 6"/> 
           </Rectangle.Clip> 
          </Rectangle> 
          <Rectangle x:Name="VerticalCenterElement" Fill="{StaticResource PhoneForegroundBrush}" Height="21" Width="7" VerticalAlignment="Top" RadiusX="5" RadiusY="5"> 
           <Rectangle.RenderTransform> 
            <TranslateTransform/> 
           </Rectangle.RenderTransform> 
          </Rectangle> 
         </Grid> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 


<Slider HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Vertical" Width="80" Height="492" Margin="177,43,0,72" Style="{StaticResource backgroundSliderAlpha}"/> 
+0

嗨帕蒂爾,感謝您的回覆。你能告訴我應該如何應用這個列表框或longlistselector。我是新手到Windows Phone 8。 – user2636874

相關問題