The code I kept writing was move the location of a shape, such as in drag-n-drop.
I've written this as an Extension method, giving:
public static class XamlExtensions
{
public static void PointSet(this DependencyObject shape, Point newLocation)
{
shape.SetValue(Canvas.LeftProperty, newLocation.X);
shape.SetValue(Canvas.TopProperty, newLocation.Y);
}
}
which allows:
shape.PointSet(cursorPoint);
rather than
PointSet(shape, cursorPoint);
No comments:
Post a Comment