Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Track Class

Represents a control primitive that handles the positioning and sizing of a Thumb control and two RepeatButton controls that are used to set a Value.

Namespace: System.Windows.Controls.Primitives
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] 
public class Track : FrameworkElement
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */ 
public class Track extends FrameworkElement
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) 
public class Track extends FrameworkElement

The Track control is typically implemented as part of the ControlTemplate of a RangeBase control that can have a range of values, such as the ScrollBar and Slider controls. The Track provides a Thumb control and two RepeatButton controls that are used to change the Value of the Track control. The following table shows the Track properties and the corresponding RangeBase properties to which they automatically bind. When either property changes, the bound property also changes.

Track Property

RangeBase Property

Track.Maximum

RangeBase.Maximum

Track.Minimum

RangeBase.Minimum

Track.Value

RangeBase.Value

The following table shows the Track properties and the corresponding ScrollBar properties to which they bind when a Track is part of a ScrollBar control and the Track properties are not explicitly set for the Track control.

Track Property

ScrollBar Property

Orientation

Orientation

ViewportSize

ViewportSize

The following table shows the Track properties and the corresponding Slider properties to which they bind when a Track is part of a Slider control and the Track properties are not explicitly set for the Track control.

Track Property

Slider Property

Track.Orientation

Slider.Orientation

Track.IsDirectionReversed

Slider.IsDirectionReversed

Additionally, the Delay properties for the RepeatButton controls for a Slider control bind with the Delay properties for the RepeatButton controls of the Track control.

When a Track is used to scroll content, the size of the Thumb control is proportional to the percentage of the content that appears in the viewable area or viewport. The following illustration shows an example of a ScrollViewer control that implements a Track control.

A ScrollBar that has a Track control

ScrollBar illlustration

The following calculation is used to compute the size of the Thumb.

thumbSize = (viewportSize/(maximum-minimum+viewportSize))×trackLength

The viewportSize parameter is the value of the ViewportSize property. The maximum and minimum parameters correspond to the Maximum and Minimum property values. The value of the expression maximum-minimum+viewportSize is the size of the scrollable content. Note that the value of the Maximum property represents the Value of the Track when the content is scrolled to the bottom. This Maximum value is not the same as the length or extent of the content. For a more detailed explanation, see Maximum.

The Value of a Track in a ScrollBar increases from top to bottom or from left to right depending on the orientation of the ScrollBar. Similarly, the Value of a Track in a Slider increases from bottom to top or from left to right depending on the orientation of the Slider. To change the direction of increasing value, set the IsDirectionReversed property of the Track to true.

The following example shows how to define a Track control in a ScrollBar ControlTemplate. For the complete sample, see Custom ScrollBar Template Sample.

<ControlTemplate TargetType="{x:Type ScrollBar}">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="12"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="12" />
      <RowDefinition Height="*"/>
      <RowDefinition Height="12" />
    </Grid.RowDefinitions>
    <Border Grid.Row="1" BorderThickness="0" 
            Background="Transparent" CornerRadius="4"/>
    <RepeatButton Grid.Row="0" 
                  Style="{DynamicResource Scrollbar_LineButton}" 
                  Command="ScrollBar.LineUpCommand" Content=" ^" />
    
    <!--IsDirectionReversed set to true draws a ScrollBar with a 
        Track whose lowest value is at the bottom.
        The default orientation of a ScrollBar is for the Track
        values to decrease from top to bottom.-->
    <Track Grid.Row="1" Name="PART_Track"
           IsDirectionReversed="true">
      <Track.DecreaseRepeatButton>
        <RepeatButton Style="{DynamicResource ScrollBar_UpTrack}"/>
      </Track.DecreaseRepeatButton>
      <Track.Thumb>
        <Thumb Style="{DynamicResource ScrollBar_HorizontalThumb}"/>
      </Track.Thumb>
      <Track.IncreaseRepeatButton>
        <RepeatButton Style="{DynamicResource ScrollBar_DownTrack}"/>
      </Track.IncreaseRepeatButton>
    </Track>
    <RepeatButton Grid.Row="2" 
                  Style="{DynamicResource Scrollbar_LineButton}" 
                  Command="ScrollBar.LineDownCommand" Content=" v" />
  </Grid>
</ControlTemplate>

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
            System.Windows.Controls.Primitives.Track

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

Show:
© 2014 Microsoft