Disable viewbox for specific children
Hi!
I wanted to ask if there's some way to disable viewbox scaling for one specific image. I have a complicated user control that is inside the Viewbox, and inside that control is one image that I do not want to scale. I do not want to move the image outside that user control, since I want it to be rendered in between other elements (and it would also be quite complicated in general).
One solution that I've found here https://www.codeproject.com/Articles/11 ... c-Elements creates an inverse scaling transform. It seems like that would work (however I worry if it would degrade the image quality ie. make it downscale and then upscale again, or if the backend implementation is smart enough to see that the viewbox and scale transform should cancel out). I cannot get it to work in Noesis though, since it uses the following line to get the viewbox's transform
and the ContainerVisual is not accessible in the C# Noesis NuGet package. Is there something I could do to work around the lack of ContainerVisual issue? Or maybe some completely other way to disable the viewbox scaling for one specific image.
I wanted to ask if there's some way to disable viewbox scaling for one specific image. I have a complicated user control that is inside the Viewbox, and inside that control is one image that I do not want to scale. I do not want to move the image outside that user control, since I want it to be rendered in between other elements (and it would also be quite complicated in general).
One solution that I've found here https://www.codeproject.com/Articles/11 ... c-Elements creates an inverse scaling transform. It seems like that would work (however I worry if it would degrade the image quality ie. make it downscale and then upscale again, or if the backend implementation is smart enough to see that the viewbox and scale transform should cancel out). I cannot get it to work in Noesis though, since it uses the following line to get the viewbox's transform
Code: Select all
var transform =
((ContainerVisual)VisualTreeHelper.GetChild(sender as DependencyObject, 0)).Transform;
if (transform != null && viewBox != null)
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Disable viewbox for specific children
Hi,
The transforms will cancel before any rendering is performed, so the image quality won't be affected.
In order to get the scale applied by the Viewbox you can do the following in Noesis:
Then you can just apply the inverse scaling to your image.
The transforms will cancel before any rendering is performed, so the image quality won't be affected.
In order to get the scale applied by the Viewbox you can do the following in Noesis:
Code: Select all
ScaleTransform scale = ((UIElement)VisualTreeHelper.GetChild(viewbox, 0)).RenderTransform as ScaleTransform;
Who is online
Users browsing this forum: No registered users and 17 guests