I need to figure out how to change the UserControl's
Width
and Height
at runtime. I am trying to do this during a mouseMove
event. The Width
and Height
are set to Auto
in XAML
.
'mouseDown event
mouseVerticalPosition = e.GetPosition(Nothing).Y
mouseHorizontalPosition = e.GetPosition(Nothing).X
'mouseMove event
Dim deltaV As Double = e.GetPosition(Nothing).Y - mouseVerticalPosition
Dim deltaH As Double = e.GetPosition(Nothing).X - mouseHorizontalPosition
Me.Width = Me.Width + deltaH
UpdateLayout() 'does not work
This code is inside of the UserControl
not the Page
where the UserControl
lives - if that helps.
Consider the container and it's properties - auto and stretch are used here:
<Grid x:Name="LayoutRoot" Background="Transparent" >
<Canvas Name="cnv" Margin="18">
<Rectangle Name="Rect" Margin="0" />
</Canvas>
</Grid>