ad38e4d3e1
This reverts commit 00a338c202.
80 lines
3.5 KiB
VB.net
80 lines
3.5 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:EgtPanelWindow/>
|
|
'
|
|
|
|
<TemplatePart(Name:="PART_MoveRectangle", Type:=GetType(Rectangle))>
|
|
Public Class EgtPanelWindow
|
|
Inherits System.Windows.Window
|
|
|
|
Private m_MoveRectangle As Rectangle
|
|
|
|
' Proprietà che permette di impostare l'altezza della TitleBar
|
|
Public Shared ReadOnly TitleBarHeightProperty As DependencyProperty = DependencyProperty.Register("TitleBarHeight", GetType(Double), GetType(EgtPanelWindow), New PropertyMetadata(10.0))
|
|
Public Property TitleBarHeight() As Double
|
|
Get
|
|
Return CType(GetValue(TitleBarHeightProperty), Double)
|
|
End Get
|
|
Set(ByVal value As Double)
|
|
SetValue(TitleBarHeightProperty, value)
|
|
End Set
|
|
End Property
|
|
|
|
' Proprietà che permette di impostare l'orientamento della finestra per posizionare la TitleBar
|
|
Public Shared ReadOnly TitleBarOrientationProperty As DependencyProperty = DependencyProperty.Register("TitleBarOrientation", GetType(System.Windows.Controls.Orientation), GetType(EgtPanelWindow), New PropertyMetadata(System.Windows.Controls.Orientation.Vertical))
|
|
Public Property TitleBarOrientation() As System.Windows.Controls.Orientation
|
|
Get
|
|
Return CType(GetValue(TitleBarOrientationProperty), System.Windows.Controls.Orientation)
|
|
End Get
|
|
Set(ByVal value As System.Windows.Controls.Orientation)
|
|
SetValue(TitleBarOrientationProperty, value)
|
|
End Set
|
|
End Property
|
|
|
|
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(EgtPanelWindow), New FrameworkPropertyMetadata(GetType(EgtPanelWindow)))
|
|
End Sub
|
|
|
|
Public Overrides Sub OnApplyTemplate()
|
|
MyBase.OnApplyTemplate()
|
|
' Retrieve the Button from the current template
|
|
m_MoveRectangle = TryCast(MyBase.GetTemplateChild("PART_MoveRectangle"), Rectangle)
|
|
' Hook up the event handler
|
|
If m_MoveRectangle IsNot Nothing Then
|
|
AddHandler m_MoveRectangle.PreviewMouseDown, AddressOf MoveRectangle_PreviewMouseDown
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub MoveRectangle_PreviewMouseDown(sender As Object, e As System.Windows.Input.MouseButtonEventArgs)
|
|
If e.LeftButton = MouseButtonState.Pressed Then
|
|
Me.DragMove()
|
|
End If
|
|
End Sub
|
|
|
|
End Class |