is there a way to access mdebDrawingArea.X (and Y)?
I mean my rectangle is inside a grid and once I dragged it around I need to know its final offset. I thought to get access to X and Y property because I noticed Margin property of the rectangle is not updated.
Thank you all!
MouseDragElementBehavior
If the reply helps you, please kindly mark the post as answer.
Follow me on Twitter:@parseval
Here is a code where you can track what is the position of X and Y co-ordinates-
1) I have applied the behavior by code. The class MouseDragElementBehavior contains few events. One of them is DragFinished. You can get the co-ordinates within that event as well. Look at the code below-
a.pierini
Participant
1015 Points
337 Posts
MouseDragElementBehavior: accessing coordinates
Aug 14, 2009 12:36 PM | LINK
Hi,
in this piece of code
<
Rectangle x:Name="rctDrawingArea" Fill="#55FFFFFF" Stroke="Black"> <i:Interaction.Behaviors> <il:MouseDragElementBehavior x:Name="mdebDrawingArea" ConstrainToParentBounds="True"/> </i:Interaction.Behaviors> </Rectangle>is there a way to access mdebDrawingArea.X (and Y)?
I mean my rectangle is inside a grid and once I dragged it around I need to know its final offset. I thought to get access to X and Y property because I noticed Margin property of the rectangle is not updated.
Thank you all!
MouseDragElementBehavior
Follow me on Twitter:@parseval
www.rosemakeup.com
DJanjicek
Participant
1575 Points
487 Posts
Re: MouseDragElementBehavior: accessing coordinates
Aug 14, 2009 10:09 PM | LINK
I'm not aware of your code, but if it's something like this http://www.rick-sammons.com/?tag=/mousedragelementbehavior you can use the eventhandler to receive the x/y coordinates which are exposed by MouseEventArgs
void Bla(object sender, System.Windows.Forms.MouseEventArgs e)
{
MessageBox.Show("X: " + e.X.ToString() + " " + "Y: " + e.Y.ToString());
}
Pravinkumar...
Contributor
5034 Points
801 Posts
Re: MouseDragElementBehavior: accessing coordinates
Aug 15, 2009 02:24 PM | LINK
Hi,
Here is a code where you can track what is the position of X and Y co-ordinates-
1) I have applied the behavior by code. The class MouseDragElementBehavior contains few events. One of them is DragFinished. You can get the co-ordinates within that event as well. Look at the code below-
USER Control-
<
UserControlxmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns
:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns
:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:il="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions"x
:Class="SampleProject.MainPage"Width
="640" Height="480"> <Grid x:Name="LayoutRoot" Background="White"><TextBlock x:Name="txtcordinates" FontSize="20" Foreground="Blue"/>
<Rectangle Fill="Red" Stroke="Black" Margin="144,88,160,192" x:Name="rect1"/> </Grid></
UserControl>UserControl Code in CS file-
Import a namespace in .CS file codebehind of MainPage.XAML
using
Microsoft.Expression.Interactivity.Layout;Silverlight 3.0