How to make a WPF UserControl movable?

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top