Public
Class
CustomScrollViewer
Inherits
ScrollViewer
Shared
Sub
New
()
DefaultStyleKeyProperty.OverrideMetadata(
GetType
(CustomScrollViewer),
FrameworkPropertyMetadata(
(CustomScrollViewer)))
End
Property
ScrollBarThumbBrush
As
Brush
Get
Return
GetValue(ScrollBarThumbBrushProperty)
Set
(
ByVal
value
Brush)
SetValue(ScrollBarThumbBrushProperty, value)
ReadOnly
ScrollBarThumbBrushProperty
DependencyProperty = DependencyProperty.Register(
"ScrollBarThumbBrush"
,
(Brush),
(CustomScrollBar),
PropertyMetadata(Brushes.Gray))
<
Style
TargetType
=
"my:CustomScrollViewer"
>
Setter
"Template"
Setter.Value
ControlTemplate
Grid
x:Name
"Grid"
Background
"{TemplateBinding Background}"
Grid.ColumnDefinitions
ColumnDefinition
Width
"*"
/>
"Auto"
</
Grid.RowDefinitions
RowDefinition
Height
Rectangle
"Corner"
Grid.Column
"1"
Fill
"{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
Grid.Row
ScrollContentPresenter
"PART_ScrollContentPresenter"
CanContentScroll
"{TemplateBinding CanContentScroll}"
CanHorizontallyScroll
"False"
CanVerticallyScroll
ContentTemplate
"{TemplateBinding ContentTemplate}"
Content
"{TemplateBinding Content}"
"0"
Margin
"{TemplateBinding Padding}"
ScrollBar
"PART_VerticalScrollBar"
AutomationProperties.AutomationId
"VerticalScrollBar"
Cursor
"Arrow"
Maximum
"{TemplateBinding ScrollableHeight}"
Minimum
Visibility
"{TemplateBinding ComputedVerticalScrollBarVisibility}"
Value
"{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
ViewportSize
"{TemplateBinding ViewportHeight}"
"PART_HorizontalScrollBar"
"HorizontalScrollBar"
"{TemplateBinding ScrollableWidth}"
Orientation
"Horizontal"
"{TemplateBinding ComputedHorizontalScrollBarVisibility}"
"{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
"{TemplateBinding ViewportWidth}"
Fill="{Binding Path=ScrollBarThumbBrush, RelativeSource={RelativeSource AncestorType=my:CustomScrollViewer}}"
"ScrollBar"
"Stylus.IsPressAndHoldEnabled"
"Stylus.IsFlicksEnabled"
"Background"
"#FFF0F0F0"
"BorderBrush"
"Foreground"
"{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
"BorderThickness"
"1,0"
"Width"
"{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
"MinWidth"
"Bg"
SnapsToDevicePixels
"True"
MaxHeight
"{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"
"1E-05*"
Border
BorderBrush
"{TemplateBinding BorderBrush}"
BorderThickness
"{TemplateBinding BorderThickness}"
RepeatButton
"PART_LineUpButton"
Command
"ScrollBar.LineUpCommand"
IsEnabled
"{TemplateBinding IsMouseOver}"
RepeatButton.Style
"{x:Type RepeatButton}"
"FocusVisualStyle"
"Control.Template"
"2"
Stroke
StrokeThickness
StrokeDashArray
"1 2"
"HorizontalContentAlignment"
"Center"
"VerticalContentAlignment"
"Padding"
"Focusable"
"IsTabStop"
"border"
ContentPresenter
"contentPresenter"
ContentStringFormat
"{TemplateBinding ContentStringFormat}"
Focusable
HorizontalAlignment
"{TemplateBinding HorizontalContentAlignment}"
"{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment
"{TemplateBinding VerticalContentAlignment}"
ControlTemplate.Triggers
Trigger
"IsMouseOver"
TargetName
"#FFDADADA"
"IsPressed"
"#FF606060"
"IsEnabled"
"Opacity"
"0.56"
Path
"ArrowTop"
Data
"M0,4C0,4 0,6 0,6 0,6 3.5,2.5 3.5,2.5 3.5,2.5 7,6 7,6 7,6 7,4 7,4 7,4 3.5,0.5 3.5,0.5 3.5,0.5 0,4 0,4z"
"3,4,3,3"
Stretch
"Uniform"
Track
"PART_Track"
IsDirectionReversed
Track.DecreaseRepeatButton
"ScrollBar.PageUpCommand"
"OverridesDefaultStyle"
"Transparent"
"{TemplateBinding Height}"
"{TemplateBinding Width}"
Track.IncreaseRepeatButton
"ScrollBar.PageDownCommand"
Track.Thumb
Thumb
Thumb.Style
"{x:Type Thumb}"
"rectangle"
"{Binding Path=ScrollBarThumbBrush, RelativeSource={RelativeSource AncestorType=my:CustomScrollViewer}}"
"Fill"
"#FFA6A6A6"
"IsDragging"
"PART_LineDownButton"
"ScrollBar.LineDownCommand"
"ArrowBottom"
"M0,2.5C0,2.5 0,0.5 0,0.5 0,0.5 3.5,4 3.5,4 3.5,4 7,0.5 7,0.5 7,0.5 7,2.5 7,2.5 7,2.5 3.5,6 3.5,6 3.5,6 0,2.5 0,2.5z"
MultiDataTrigger
MultiDataTrigger.Conditions
Condition
Binding
"{Binding IsMouseOver, ElementName=PART_LineDownButton}"
"true"
"{Binding IsPressed, ElementName=PART_LineDownButton}"
"White"
"{Binding IsMouseOver, ElementName=PART_LineUpButton}"
"{Binding IsPressed, ElementName=PART_LineUpButton}"
"false"
"Black"
"#FFBFBFBF"
Style.Triggers
"Orientation"
"Height"
"{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"
"MinHeight"
"0,1"
"{x:Type ScrollBar}"
MaxWidth
"{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"
"PART_LineLeftButton"
"ScrollBar.LineLeftCommand"
"ArrowLeft"
"M3.18,7C3.18,7 5,7 5,7 5,7 1.81,3.5 1.81,3.5 1.81,3.5 5,0 5,0 5,0 3.18,0 3.18,0 3.18,0 0,3.5 0,3.5 0,3.5 3.18,7 3.18,7z"
"3"
"ScrollBar.PageLeftCommand"
"ScrollBar.PageRightCommand"
"PART_LineRightButton"
"ScrollBar.LineRightCommand"
"ArrowRight"
"M1.81,7C1.81,7 0,7 0,7 0,7 3.18,3.5 3.18,3.5 3.18,3.5 0,0 0,0 0,0 1.81,0 1.81,0 1.81,0 5,3.5 5,3.5 5,3.5 1.81,7 1.81,7z"
"{Binding IsMouseOver, ElementName=PART_LineRightButton}"
"{Binding IsPressed, ElementName=PART_LineRightButton}"
"{Binding IsMouseOver, ElementName=PART_LineLeftButton}"
"{Binding IsPressed, ElementName=PART_LineLeftButton}"
</Style>
my:CustomScrollViewer
"Blue"
HorizontalScrollBarVisibility
"Visible"
VerticalScrollBarVisibility
"600"