UWP Measure Textblock DesiredSize in Background - xaml

I have a textblock with text and fontsize. I can find the desired size for the textblock using Textblock.Measure(), but this has to be done in the background. Is there a way to compute this in background (Task.Run).

Related

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?

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.

How to handle Segoe UI in pixel perfect layout (glyph "margin")

i am fighting with the layout of my windows store app. My problem is with the segoe ui font that I am using for the labels of some textboxes.
I have a borderless label above a textbox with a border like this:
LABEL
_____________
|__TEXTBOX___|
My problem is, that the font of the label does not align perfectly with the left border of the textbox.
First I though that it must be the label padding or something, maybe a padding or margin in the control template. But this is not the case. The true reason is the space around the glyphs within the font itself. Depending on the first letter or the size of the font the gap is bigger or smaller.
Is there a way to perfectly align the label text and the textbox independant of the first letter or the font size? Or do I really have to place every label in a different position to reduce this problem?

Sizing of viewbox content

I'm trying to get my head around using a viewbox container. I have a simple viewbox control and within it i have a simple button.
As expected this button is made the size of the veiwbox. How do i re-size the button to an acceptable size yet so it will grow when viewing on higher screen resolutions.

How to find the size occupied by the text in NSTextField?

I have a NSTextField(Label) in a NSView. Value in the label changes dynamically. I would like to set the Frame of the TextField always centered with respect to view.Is there any way to calculate the pixels or size occupied by the text in the texfield so that I can increase the size of the textfield to fit the text and change the origin so that textfield is always centered.
I would like to align the NSTextField to be Centered with in a View and Change the origin and frame of the textfield by calculating the size occupied by text. How to calculate the size occupied by the text in the TextField ?
Unless the label has a background color the easiest thing is to size it to be as large as your UI can possibly allow and then set your text justification to be centering. You can do this in Interface Builder by just selecting the centering tab under "Alignment" in the Attributes Inspector for the label.

GTK: Resizing widgets contained in a textview

I have a Gtk.TextView control, and I'm inserting child widgets into it. I'd like to be able to have the children resize to fit the width of the TextView when the form is resized. Is there a built-in way to do this? If not, can anyone suggest a good way of writing my own?
You can use the gtk_text_view_get_window() method to get the width of the Gtk.TextView. With this number you can resize your child-widget accordingly. If you want to resize the child-widget automatically when the Gtk.TextView resizes, you can use the signal check-resize, to do the resizing.