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 7646111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:07:28+00:00 2026-05-31T10:07:28+00:00

I have subclassed the image control (to display images at their true pixel size,

  • 0

I have subclassed the image control (to display images at their true pixel size, regardless of resolution setting in metadata) and I want to implement scrolling and zooming, by using a ScaleTransform (within a LayoutTransform). This works fine at 100%, but when scaled the scrolling size stays at the size of the 100% image.

My XAML is:

<ScrollViewer Name="imgScrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
    <PL:DpiAgnosticImage x:Name="Ctrl_ImgMain" Stretch="None" HorizontalAlignment="Left" MouseWheel="Ctrl_ImgMain_MouseWheel" VerticalAlignment="Top"   >
         <Image.LayoutTransform>
              <ScaleTransform ScaleX="{Binding ZoomLevel}" ScaleY="{Binding ZoomLevel}">
              </ScaleTransform>
         </Image.LayoutTransform>
    </PL:DpiAgnosticImage>
</ScrollViewer>

The C# for my DpiAgnosticImage class is:

class DpiAgnosticImage : Image
{
    protected override Size MeasureOverride(Size constraint)
    {
        var bitmapImage = Source as BitmapImage;

        var desiredSize = bitmapImage == null
            ? base.MeasureOverride(constraint)
            : new Size(bitmapImage.PixelWidth, bitmapImage.PixelHeight);

        return desiredSize;
    }

    protected override Size ArrangeOverride(Size finalSize)
    {
        return new Size(Math.Round(DesiredSize.Width), Math.Round(DesiredSize.Height));
    }
}

I’ve searched around but the closest that I have found to this problem suggests using LayoutTransform – which I already am.
I suspect that I need to implement something to change the scrollviewer size when the image is scaled, but I am struggling to find out what is required. Any suggestions would be appreciated.

  • 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-31T10:07:31+00:00Added an answer on May 31, 2026 at 10:07 am

    Your derived image control works fine if you simply don’t override ArrangeOverride.

    Apparently the DesiredSize property gets the size calculated by MeasureOverride and subsequently transformed by LayoutTransform. This might by obvious during layout, although it doesn’t seem to be well documented in the MSDN of DesiredSize and MeasureOverride.

    Found this in Charles Petzold, “Applications=Code+Markup”, p.831:

    The DesiredSize property of an element’s child reflects the
    LayoutTransform, …

    Anyway, if you need to override ArrangeOverride for any other reason, simply return the value of the finalSize argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a UIView subclass that has a border image, but I
I have subclassed a control in C# WinForms, and am custom drawing text in
I have subclassed a UITableViewCell and within this class I want to get it's
I have few custom controls (image views) added programmatically to table cell. I want
I have subclassed a graphics control that takes a device context handle, HDC, as
I'm using visual studio 2008 I have a control that dispays a processed image.
I want to use UITableViewCells within my application which have an image, and that
I have subclassed a tableview cell and added a couple of labels and images
I have a subclass of UIScrollView that I'm using for images slideshow, with infinite
I have subclassed Form to include some extra functionality, which boils down to a

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.