How to make a WPF UserControl movable?

  • Thread starter Thread starter sowen
  • Start date Start date
S

sowen

Hi,

I am pretty new in WPF.

Now I am having a UserControl with two rectangles and one textblock. I
want to enable the animation to this control. How exactly can I do
that?

My simple user control is as follows:

<UserControl x:Class="WPFTest.ExpandedRectangle"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="80" Width="160">
<Grid>
<Rectangle Width="160" Height="80" Fill="Transparent"
Name="BackRect"></Rectangle>
<Rectangle Width="100" Height="40" Stroke="Black"
Focusable="True" Name="TextRect" Fill="LightGray"></Rectangle>
<TextBlock Text="Expanded Target" Margin="38,32,40,32"
Name="TargetText"></TextBlock>
</Grid>
</UserControl>

Thank you very much!
 
Back
Top