I am writing a WPF application that displays an image that is initially centered. The user can enlarge / reduce the image and move the image, which is implemented using ScaleTransform and TranslateTransform . This works great.
The problem is that the image is much larger than the window, and the user moves the image or scales enough to make the whole image visible. The part of the image that was originally hidden is not displayed, and instead only the originally viewed part of the image is drawn.
Based on some other questions , if I put my image inside a Canvas which will cause the whole image to display, and when moving it will display correctly. The problem is that I donβt want my image to be in Canvas , since this prevents any other layout from appearing - the HorizontalAlignment and VerticalAlignment properties are ignored (so the image is no longer centered), and I need to implement an option that will make the image as possible large to fill the entire area of ββthe window that no longer works (setting the Stretch property to UniformToFill does nothing).
Currently, two transforms have the RenderTransform property RenderTransform . If I use LayoutTransform , the entire image will be drawn, but it will also not allow the user to move any part of the image from the edge of the window (this is the behavior I would like to preserve).
How can I say that WPF always displays the whole image without using Canvas or LayoutTransform ?
source share