I have image A and text field B(no label) in a container C.
Let E be container C width - image A width
Container C is in container D.
Container C has some start height.
Container C is filling container D in width(so container D is controlling width).
Image A has const width.
I want text field B:
Start near image A.
If text width is less than E width:
– Have minimal width(text field background with not filling out container C, just enough for text)
– Have stretched height(same height as container C)
If text width is more than E width:
– Do not extend container C in width, create another line
– Possibly extend container C in height
I don’t know how to do this. I can only do:
Correct height, bad align(starts near right border of container C) and expands container C width when text is more than E width
Correct height, correct align, doesn’t expand container C width, but stretched in width and also doesn’t expand container C height.
Yes, set what you can in the style sheet or inline, then use geometry event to fix the rest, but use resolvedStyle rather than style to get the right values.
Thanks for suggestions, I needed justify-content and rest I figured out with GeometryChangedEvent.
Last obstacle I stumbled upon: I wanted to move the changes from code to uss file.
But for some reason values are ignored
.ContainerC
{
min-height: 40px;
flex-direction: row;
align-items: center;
justify-content: flex-start; <-- this is for sure ignored i.e. :(
}
.TextFieldB
{
min-height: 40px; <-- this as well
white-space: normal;
align-self: stretch;
flex-wrap: wrap;
}
The style will be overridden if there is a more specific selector, or if an inline style is set somewhere (can be in c#, on directly on the UXML of the element).
You can use the UI debugger (window->UI Toolkit->Debugger) to see what is the resulting style applied to the element and the source (inherited, the applicable stylesheet, etc)
Don’t hesitate to share back any question you may have.