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

  • Home
  • SEARCH
  • 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 1090701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:24:45+00:00 2026-05-16T23:24:45+00:00

Ok, So I have a situation, where an border is being scaled (sometimes by

  • 0

Ok,

So I have a situation, where an border is being scaled (sometimes by a large amount) and translated. Inside the border is a grid, and inside the grid are two images, one is a photo and is stretched to the size of the border, and the other, I intend on being an icon, which needs to be a fixed size in the bottom left hand corner.

The problem is, that I want to remove the effect scaling is having on the icon. This is because I’ve given the icon a fixed size and would like it to remain that size, but unfortunately the scaling from the border is propagating down the the children of the border and effecting them also.

So I’ve tried using an attached property, similar to this pixel snapping artical (http://blogs.msdn.com/b/devdave/archive/2008/06/22/using-an-attached-dependencyproperty-to-implement-pixel-snapping-as-an-attached-behavior.aspx), but it doesn’t seem to make a difference. When steped through, the elements which are being modified in LayoutUpdate always seem to have the identity matrix for the render transform anyway, before I’ve set it.

I guess I’m miss-interperating how render transforms are applied to children maybe?

Anyway, this is what I have (Also, I know this (if it worked) would remove translation too, which isn’t what I want!):

    public static readonly DependencyProperty IsConstantSizeProperty = 
        DependencyProperty.RegisterAttached(
        "ConstantWidth",
        typeof(bool),
        typeof(ItemsControlEX),
        new PropertyMetadata(new PropertyChangedCallback(IsConstantSizeChanged)));

    private static List<FrameworkElement> m_constSizeObjects = new List<FrameworkElement>();

    private static void IsConstantSizeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
    {
        bool isConstantWidth = (bool)args.NewValue;
        if (isConstantWidth)
        {
            FrameworkElement el = (FrameworkElement)obj;
            m_constSizeObjects.Add(el);

            el.LayoutUpdated += new EventHandler(el_LayoutUpdated);
            el.Unloaded += new RoutedEventHandler(el_Unloaded);
        }
    }

    static void el_Unloaded(object sender, RoutedEventArgs e)
    {
        FrameworkElement el = (FrameworkElement)sender;
        el.Unloaded -= new RoutedEventHandler(el_Unloaded);
        el.LayoutUpdated -= new EventHandler(el_LayoutUpdated);

        m_constSizeObjects.Remove(el);
    }

    static void el_LayoutUpdated(object sender, EventArgs e)
    {
        foreach (FrameworkElement el in m_constSizeObjects)
        {
            MatrixTransform trans = new MatrixTransform();
            trans.Matrix = Matrix.Identity;
            el.RenderTransform = trans;
        }
    }

    public static void SetIsConstantWidth(UIElement element, Boolean value)
    {
        element.SetValue(IsConstantSizeProperty, value);
    }

    public static Boolean GetIsConstantWidth(UIElement element)
    {
        return (Boolean)element.GetValue(IsConstantSizeProperty);
    }

I’m thinking I’m probably thinking about this in completely the wrong way maybe. I guess the sensible solution would be to refactor to remove the need for scaling, but I guess I was just after a quicker solution that I can use until I have time.

Any help is appreciated! 🙂

Thanks!

Andy.

  • 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-16T23:24:46+00:00Added an answer on May 16, 2026 at 11:24 pm

    If you are only scaling (I assume fixed aspect ratio) that seems overly complicated, why not place the photo in a ViewBox container? Place the ViewBox (containing the photo) and the icon (in that order) in a parent grid.

    • Make the icon relative to the bottom
      left using alignment and margin
      settings
    • Resize the viewbox to scale your image.

    The grid will shrink to fit the viewbox size. The icon will remain relative to the grid bottom-left.

    Your pixel snapping behaviour should work on a ViewBox.

    If you need a specific example, please provide some of your Xaml to work from.

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

Sidebar

Related Questions

I have a situation where I have two entities that share a primary key
I have a situation where I have two models, companies and permissions, where companies
I have a situation where I want to copy the output assembly from one
I have situation, where I want to read configuration file only one time, when
We have a situation where users are allowed to upload content, and then separately
We have a situation in our product where for a long time some data
I have a situation where I might have multiple instances of a program running
I have the situation where i use GIS software which stores the information about
I have a situation where I want to create a signature of a data
I have a situation where another developer is including source files from a project

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.