ad38e4d3e1
This reverts commit 00a338c202.
128 lines
5.9 KiB
VB.net
128 lines
5.9 KiB
VB.net
' Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
|
|
'
|
|
' Step 1a) Using this custom control in a XAML file that exists in the current project.
|
|
' Add this XmlNamespace attribute to the root element of the markup file where it is
|
|
' to be used:
|
|
'
|
|
' xmlns:MyNamespace="clr-namespace:EgtWPFLib5"
|
|
'
|
|
'
|
|
' Step 1b) Using this custom control in a XAML file that exists in a different project.
|
|
' Add this XmlNamespace attribute to the root element of the markup file where it is
|
|
' to be used:
|
|
'
|
|
' xmlns:MyNamespace="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
|
|
'
|
|
' You will also need to add a project reference from the project where the XAML file lives
|
|
' to this project and Rebuild to avoid compilation errors:
|
|
'
|
|
' Right click on the target project in the Solution Explorer and
|
|
' "Add Reference"->"Projects"->[Browse to and select this project]
|
|
'
|
|
'
|
|
' Step 2)
|
|
' Go ahead and use your control in the XAML file. Note that Intellisense in the
|
|
' XML editor does not currently work on custom controls and its child elements.
|
|
'
|
|
' <MyNamespace:EgtScrollViewer/>
|
|
'
|
|
|
|
Imports System.Windows.Controls.Primitives
|
|
|
|
Public Class EgtScrollViewer
|
|
Inherits System.Windows.Controls.ScrollViewer
|
|
|
|
' Proprietà che permette di definire la dimensione dei bottoni di movimento dello scrollViewer
|
|
Public Shared ReadOnly RepeatButtonDimensionProperty As DependencyProperty = DependencyProperty.Register("RepeatButtonDimension", GetType(Double), GetType(EgtScrollViewer), New PropertyMetadata(20.0))
|
|
Public Property RepeatButtonDimension() As Double
|
|
Get
|
|
Return CType(GetValue(RepeatButtonDimensionProperty), Double)
|
|
End Get
|
|
Set(ByVal value As Double)
|
|
SetValue(RepeatButtonDimensionProperty, value)
|
|
End Set
|
|
End Property
|
|
|
|
' Proprietà che permette di definire la dimensione dei bottoni di movimento dello scrollViewer
|
|
Public Shared ReadOnly RepeatButtonStyleProperty As DependencyProperty = DependencyProperty.Register("RepeatButtonStyle", GetType(Style), GetType(EgtScrollViewer), New PropertyMetadata(Nothing))
|
|
Public Property RepeatButtonStyle() As Style
|
|
Get
|
|
Return CType(GetValue(RepeatButtonStyleProperty), Style)
|
|
End Get
|
|
Set(ByVal value As Style)
|
|
SetValue(RepeatButtonStyleProperty, value)
|
|
End Set
|
|
End Property
|
|
|
|
' Proprietà che permette di definire la dimensione dei bottoni di movimento dello scrollViewer
|
|
Public Shared ReadOnly IsPageSlideCommandProperty As DependencyProperty = DependencyProperty.Register("IsPageSlideCommand", GetType(Boolean), GetType(EgtScrollViewer), New PropertyMetadata(False))
|
|
Public Property IsPageSlideCommand() As Boolean
|
|
Get
|
|
Return CBool(GetValue(IsPageSlideCommandProperty))
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
If value Then
|
|
LeftSlideCommand = ScrollBar.PageLeftCommand
|
|
RightSlideCommand = ScrollBar.PageRightCommand
|
|
Else
|
|
LeftSlideCommand = ScrollBar.LineLeftCommand
|
|
RightSlideCommand = ScrollBar.LineRightCommand
|
|
End If
|
|
SetValue(IsPageSlideCommandProperty, value)
|
|
End Set
|
|
End Property
|
|
|
|
' Proprietà che permette di definire la dimensione dei bottoni di movimento dello scrollViewer
|
|
Public Shared ReadOnly LeftSlideCommandProperty As DependencyProperty = DependencyProperty.Register("LeftSlideCommand", GetType(System.Windows.Input.RoutedCommand), GetType(EgtScrollViewer), New PropertyMetadata(Nothing))
|
|
Public Property LeftSlideCommand() As System.Windows.Input.RoutedCommand
|
|
Get
|
|
Return CType(GetValue(LeftSlideCommandProperty), System.Windows.Input.RoutedCommand)
|
|
End Get
|
|
Set(ByVal value As System.Windows.Input.RoutedCommand)
|
|
SetValue(LeftSlideCommandProperty, value)
|
|
End Set
|
|
End Property
|
|
' Proprietà che permette di definire la dimensione dei bottoni di movimento dello scrollViewer
|
|
Public Shared ReadOnly RightSlideCommandProperty As DependencyProperty = DependencyProperty.Register("RightSlideCommand", GetType(System.Windows.Input.RoutedCommand), GetType(EgtScrollViewer), New PropertyMetadata(Nothing))
|
|
Public Property RightSlideCommand() As System.Windows.Input.RoutedCommand
|
|
Get
|
|
Return CType(GetValue(RightSlideCommandProperty), System.Windows.Input.RoutedCommand)
|
|
End Get
|
|
Set(ByVal value As System.Windows.Input.RoutedCommand)
|
|
SetValue(RightSlideCommandProperty, value)
|
|
End Set
|
|
End Property
|
|
|
|
' Proprietà che permette di definire se di tipo normale o custom
|
|
Public Shared ReadOnly IsCustomProperty As DependencyProperty = DependencyProperty.Register("IsCustom", GetType(Boolean), GetType(EgtScrollViewer), New PropertyMetadata(False))
|
|
Public Property IsCustom() As Boolean
|
|
Get
|
|
Return CBool(GetValue(IsCustomProperty))
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
SetValue(IsCustomProperty, value)
|
|
End Set
|
|
End Property
|
|
|
|
' Proprietà che permette di definire l'orientamento nel caso sia di tipo Custom
|
|
Public Shared ReadOnly OrientationProperty As DependencyProperty = DependencyProperty.Register("Orientation", GetType(Orientation), GetType(EgtScrollViewer), New PropertyMetadata(Orientation.Horizontal))
|
|
Public Property Orientation() As Orientation
|
|
Get
|
|
Return CType(GetValue(OrientationProperty), Orientation)
|
|
End Get
|
|
Set(ByVal value As Orientation)
|
|
SetValue(OrientationProperty, value)
|
|
End Set
|
|
End Property
|
|
|
|
Public Overrides Sub OnApplyTemplate()
|
|
MyBase.OnApplyTemplate()
|
|
End Sub
|
|
|
|
Shared Sub New()
|
|
'This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
|
|
'This style is defined in themes\generic.xaml
|
|
DefaultStyleKeyProperty.OverrideMetadata(GetType(EgtScrollViewer), New FrameworkPropertyMetadata(GetType(EgtScrollViewer)))
|
|
End Sub
|
|
|
|
End Class |