how to resize InkCanvas

Javier R 211 Reputation points
2023-02-08T18:37:16.6733333+00:00

How can I change the size of the InkCanvas and when zoom is enlarged to another size.

 private void SetCanvasSize()
        {
            inkCanvas.Width = Math.Max(canvasScroll.ViewportWidth, 1000);
            inkCanvas.Height = Math.Max(canvasScroll.ViewportHeight, 1000);
        }
Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Roy Li - MSFT 32,466 Reputation points Microsoft Vendor
    2023-02-09T02:36:46.9566667+00:00

    Hello,

    Welcome to Microsoft Q&A!

    How can I change the size of the InkCanvas and when zoom is enlarged to another size.

    It seems like that you are trying to resize the InkCanvas as well as the inkstrokes inside it. You could take a look at ScaleTransform. You could use ScaleTransform to scale the InkCanvas to get what you want.

    Code-behind:

      private void SetCanvasSize()
            {
                InkCanvasScaleTransform.ScaleX = 0.5;
                InkCanvasScaleTransform.ScaleY = 0.5;
    
            }
    
    

    Xaml:

    
     <InkCanvas Grid.Row="1" x:Name="inkCanvas" Width="800" Height="800" >
                <InkCanvas.RenderTransform>
                    <ScaleTransform x:Name="InkCanvasScaleTransform" />
                </InkCanvas.RenderTransform>
            </InkCanvas>
    
    

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful