Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7514049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:22:43+00:00 2026-05-30T00:22:43+00:00

When I want to scale Canvas with background it don’t work the way I

  • 0

When I want to scale Canvas with background it don’t work the way I want. The background is the same and only content of Canvas is scaling. But if I change Canvas to InkCanvas it work good but because InkCanvas don’t support MouseLeftButtonDown event I have to use Canvas.

It’s my code

 <ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Visible">
        <Canvas x:Name="CanvasChart" MouseMove="CanvasChart_MouseMove" MouseLeave="CanvasChart_MouseLeave"  
                   Grid.Column="1" Margin="20 20 20 20">
            <Canvas.Background >
                <ImageBrush Stretch="UniformToFill"  ImageSource="D:\Praca\JanarMapy\JanarMapy\Maps\Montenegro_Map.png"></ImageBrush>
            </Canvas.Background>
            <Canvas.LayoutTransform>
                <ScaleTransform 
                                ScaleX="{Binding Path=Value, ElementName=zoomSlider}"
                                ScaleY="{Binding Path=Value, ElementName=zoomSlider}"/>
            </Canvas.LayoutTransform>
        </Canvas>
    </ScrollViewer>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:22:44+00:00Added an answer on May 30, 2026 at 12:22 am

    At first you would have to disable automatic stretching of the background ImageBrush to see any scaling effect:

    <ImageBrush Stretch="None" ... />
    

    But note that a brush does not participate in layout calculations. If your intention is to resize the content of the ScrollViewer by a scaling transform you should consider the following solution, in which the Grid will always have at least the size of the Image.

    <ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
        <Grid Margin="20 20 20 20">
            <Grid.LayoutTransform>
                <ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoomSlider}" 
                                ScaleY="{Binding Path=Value, ElementName=zoomSlider}"/>
            </Grid.LayoutTransform>
            <Image Source="D:\Praca\JanarMapy\JanarMapy\Maps\Montenegro_Map.png"
                   Stretch="None"/>
            <Canvas x:Name="CanvasChart"/>
        </Grid>
    </ScrollViewer>
    

    As an alternative that works in a similar way as with InkCanvas you could set a fixed size for the Canvas:

    <ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
        <Canvas x:Name="CanvasChart" Margin="20 20 20 20"
                Width="500" Height="400">
            <Canvas.Background >
                <ImageBrush Stretch="UniformToFill" ImageSource="D:\Praca\JanarMapy\JanarMapy\Maps\Montenegro_Map.png"/>
            </Canvas.Background>
            <Canvas.LayoutTransform>
                <ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoomSlider}" 
                                ScaleY="{Binding Path=Value, ElementName=zoomSlider}"/>
            </Canvas.LayoutTransform>
        </Canvas>
    </ScrollViewer>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have canvas element and I want to scale it down, but without changing
AS in subject. I want to rotate a object but i don't want it
I want to draw a rectangle using canvas which change its size with different
I want to scale images these day and find the following example: Example #1
We want to scale, rotate and drag functionality in flash as3. I do have
I want to scale my round rectangle and keep it's radius from been changed.
I want to scale the picture to fit the main div class http://jsfiddle.net/EyW99/ Sorry,
I want to scale out my EC2 instances on AWS. For this I have
Say I have a BitmapData of 600x600 and I want to scale it down
Summary: I want a horizontal row of ImageButtons to scale down evenly to fit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.