Disable viewbox for specific children
Posted: 27 Apr 2023, 11:41
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)