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?

[Webinar] Streamline your web hosting managementRegister Today

bish wakimConnect With a Mentor Author 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

Roshan DavisConnect With a Mentor Commented:
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 ...
All Courses

From novice to tech pro — start learning today.