Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / WPF

Resizing a Custom WPF Window

Rate me:
Please Sign up or sign in to vote.
4.63/5 (8 votes)
4 Jun 2010CPOL4 min read 63.9K   2.4K   23  
Learn how to enable resizing of a custom WPF window created in Expression Blend
Class MainWindow


	Private Sub Top_DragDelta(ByVal sender as Object, ByVal e as System.Windows.Controls.Primitives.DragDeltaEventArgs)
		'TODO: Add event handler implementation here.
		If Me.Height > Me.MinHeight Then
			Me.Height -= e.VerticalChange
			Me.Top += e.VerticalChange
		Else
			Me.Height = Me.MinHeight + 4
			TopThumb.ReleaseMouseCapture()
		End If
	End Sub

	Private Sub Btm_DragDelta(ByVal sender as Object, ByVal e as System.Windows.Controls.Primitives.DragDeltaEventArgs)
		'TODO: Add event handler implementation here.
		If Me.Height > Me.MinHeight Then
			Me.Height += e.VerticalChange
		Else
			Me.Height = Me.MinHeight + 4
			BtmThumb.ReleaseMouseCapture()
		End If
	End Sub

	Private Sub Rgt_DragDelta(ByVal sender as Object, ByVal e as System.Windows.Controls.Primitives.DragDeltaEventArgs)
		'TODO: Add event handler implementation here.
		If Me.Width > Me.MinWidth Then
			Me.Width += e.HorizontalChange
		Else
			Me.Width = Me.MinWidth + 4
			RgtThumb.ReleaseMouseCapture()
		End If
	End Sub

	Private Sub Lft_DragDelta(ByVal sender as Object, ByVal e as System.Windows.Controls.Primitives.DragDeltaEventArgs)
		'TODO: Add event handler implementation here.
		If Me.Width > Me.MinWidth Then
			Me.Width -= e.HorizontalChange
			Me.Left += e.HorizontalChange
		Else
			Me.Width = Me.MinWidth + 4
			LftThumb.ReleaseMouseCapture()
		End If
	End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Kenya Kenya
Experienced C# software developer with a passion for WPF.

Awards,
  • CodeProject MVP 2013
  • CodeProject MVP 2012
  • CodeProject MVP 2021

Comments and Discussions