How can I resize or move programatically a selected area in Wpf inkCanvas

When I use selection Editing mode in an inkcanvas , I  can manully resize or move a selected area(might contain uielements or strokes). How can i perfom the same actions programatically with c#??
bish wakimAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roshan DavisCommented:
you can use MoveEnabled=True, ResizeEnabled=True in the xaml and you can use the inkCanvas Width, Height for size Canvas.Left and Canvas.Top to move in the code
bish wakimAuthor Commented:
Thank you very mush for your answer. Please explain to me your solution!
I try to expose again my question.
Say my inkcanvas(name= myink) contains children (strokes+elements sush as buttons' images...
So I can select all these children with the folowing c# line:
                     myink.Select(myink.Strokes, myink.Children.Cast<UIElement>());

I know all the selected children are living inside an AdornerLayer which permit moving and resizing
the selected block manually by the mouse.
How can I resize and move this block of selected children programatically???
You are the experts Please Help me!!!!

It must be some thing  easy to do ...
bish wakimAuthor Commented:
Below I wrote the code I found my self . The comments of roshmon were partially helpful especially for moving and resizing uielements.

InkCanvas myink = GetPage();
            Rect selectedbounds;
            myink.Select(myink.Strokes, myink.Children.Cast<UIElement>());
            selectedbounds = myink.GetSelectionBounds();
            double shiftx = selectedbounds.X;
            double shifty = selectedbounds.Y;
            StrokeCollection selectedStrokes = myink.GetSelectedStrokes();
            selectedStrokes.Transform(new Matrix(1, 0, 0, 1, -shiftx, -shifty), false);           
            selectedStrokes.Transform(new Matrix(0.75, 0, 0,0.75,0,0), false);

            //Move and resize UIelements
            ReadOnlyCollection<UIElement> selectedElements;
            selectedElements = myink.GetSelectedElements();
            double Element_deltax,Element_deltay;
            foreach (UIElement element in selectedElements)
                Element_deltax= (InkCanvas.GetLeft(element)-selectedbounds.X)*0.25d;
                Element_deltay = (InkCanvas.GetTop(element)-selectedbounds.Y)*0.25d;
                ((FrameworkElement)element).Width=((FrameworkElement)element).Width *0.75d ;
                ((FrameworkElement)element).Height = ((FrameworkElement)element).Height *0.75d;

                InkCanvas.SetLeft(element, InkCanvas.GetLeft(element)-shiftx-Element_deltax);
                InkCanvas.SetTop(element, InkCanvas.GetTop(element)-shifty -Element_deltay);

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.