How do you zoom in a scrollviewer in UWP but keep the width and height of the scrollviewer stretched to fit in the parent panel or grid column? - xaml

See the images below. One is at 78% zoom but the whole content is zoomed out but not stretching to its parent control despite having Horizontal and Vertical Alignment set to "stretch".
ScrollViewer is in a GridColumn and GridRow and the Grid is being loaded into a Frame which is a part of the NavigationView on the mainpage.
Desired effect is for the content to get smaller but fit to the width and height to show more columns in this case.

See the images below. One is at 78% zoom but the whole content is zoomed out but not stretching to its parent control despite having Horizontal and Vertical Alignment set to "stretch".
This behavior of ScrollViewer is by-deign, derive from the screenshot the DataGrid is a whole place. When we zoom in or out, The DataGrid will zoom overall. For the requirement, you could edit the DataGrid's MaxColumnWidth property when zoom.

Related

Draw rectangle on image in Avalonia

Problem : I have an image with zoom and pan attached. I need to draw rectangles over it.
What I have done : I created a Canvas as an overlay over the image and made rectangle the children of canvas. Everything works well with zoom and pan etc but if the user resizes my the window then the added rectangles starts moving from their places because the rectangle position is set with respect to top and left of canvas.
I am thinking of drawing rectangles over the image and overriding the render. Any suggestions how can I achieve it easily?

ScrollViewer IsHorizontalScrollChainingEnabled and IsHorizontalRailEnabled functionality

Can someone explain what these two properties do exactly?
IsHorizontalScrollChainingEnabled
IsHorizontalRailEnabled
I tried the first one with nested ScrollViewers, but can't find any difference in functionality. Is it enabled or disabled by default? What does it do exactly, there is no information about functionality in the docs or Google available as far as i can find.
Docs: True to enable horizontal scroll chaining from child to parent; otherwise, false.
The two properties HorizontalScrollBarVisibility (Visible/Collapsed) and HorizontalScrollMode(Enabled/Disabled) make sense to me, but in what case should i use IsHorizontalRailEnabled?
Docs: True to enable the horizontal scroll rail; otherwise, false. The default is true.
Scroll chaining
<ScrollViewer Background="Red" Height="600">
<ScrollViewer Background="Blue" Margin="50,150" Height="400" IsVerticalScrollChainingEnabled="False">
<Rectangle Height="500"/>
</ScrollViewer>
</ScrollViewer>
The outer ScrollViewer is 600px tall but its content is 700px tall.
The innter ScrollViewer is 400px tall but its content is 500px tall.
Both ScrollViewers can therefore scroll vertically to show that additional 100px of content that isn't visible.
Scroll chaining defines whether or not scrolling an inner ScrollViewer (via touch) will affect the scroll position of the outer ScrollViewer when the inner ScrollViewer is scrolled beyond the top or bottom extents.
Try scrolling the inner ScrollViewer via touch in this example. No matter what you do, you are only able to scroll the inner ScrollViewer and the outer ScrollViewer's scroll position isn't affected.
Rail
If you have a ScrollViewer with both horizontal and vertical scrolling enabled, then sometimes you want to define the touch scrolling behaviour such that motions which are "almost" in the horizontal or vertical direction are locked to the dominant axis. This is the standard behaviour when scrolling webpages on a mobile phone -- scrolling up and down the page will only scroll the page vertically and not horizontally (unless your touch motion is not "vertical enough", in which case the ScrollViewer will then pan the page instead of scrolling in only one direction).
Try it out in Edge on mobile. Zoom into a webpage and then scroll vertically, and keep scrolling without lifting your finger off the screen. See how you are only able to scroll vertically even if you move your finger horizontally (all within the same touch motion)? That's scroll rail in action.
In the above diagram, the center point is the starting point of a touch interaction within the ScrollViewer. You then move your finger (or pen, whatever) in a particular direction. If you moved your finger within a yellow region, then the ScrollViewer will "lock" the scrolling motion in either the horizontal or vertical direction. If you moved your finger into the blue region, then the ScrollViewer concludes that you weren't trying to scroll in the horizontal or vertical directions, and will pan the content in both directions as you continue to move your finger around. I hope that kind of makes sense?

Does changing the frame of the view affect renderInContext and UIGraphicsGetImageFromCurrentImageContext?

I am trying to render the image of a scroll view even to the areas which is outside the visible area of the screen. I am resizing the frame of the scroll view to include the content size width and height.After resizing, I am doing a renderInContext and finally taking the image by UIGraphicsGetImageFromCurrentImageContext.
All I am getting is a square box of black color of certain bytes. If i do not resize the frame of the view, i get the image with incorrect frame.
Does changing the frame affect renderInContext? What can i do to get the correct image after resizing?

Make a vector path in xaml responsive

I have a canvas that is within a page in XAML that contains some paths from an .ai document. I would like this to be responsive and have resize according to the proportions of the grid that it is contained on. How?
Okay I fixed it myself. Replaced the canvas with a grid, then enclosed that grid in a viewbox. All paths under the canvas now has horizontal and vertical alignment set to left and top respectively, and its Canvas.Left and Canvas.Top values are now replaced by a margin reflecting these values.

How to align the bottom of a UIView with the bottom of the screen always

I want a background image to always be aligned with the bottom of the screen regardless of screen size, iOS Version, or Personal Hotspot messages etc. But none of the interface builder alignment options seem to work in every case.
I have 2 different sized images to fit 3.5' and 4' retina which change via code but their alignment is always thrown off by 'Personal Hotspot' and other messages changing the size of the parent view.
My images are the size of the screen and should fill the whole screen always. There is a black area where tab bar and status bar will overlay.
There are buttons aligned with the background and everything gets thrown out by messages that resize the parent view.
I want the bottom of the UIImageView to be aligned with the bottom of the screen always.
have you tried the contentMode property?
theImageView.contentMode = UIViewContentModeBottom;
There is also a menu item for this in interface builder if you prefer to set it there.
then if you are using auto layout, simply add a bottom space constraint from your image view to the bottom layout guide.
If you're not using auto layout, a fixed bottom margin on the autoresizing mask should do the trick.