trying to understand the following:
<Grid Name="Root">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
</Grid>
Can anyone help me in explaining the difference between * and Auto in the above snippet?
thanks
Auto means give this column/row the size of the contained items.
* means share the rest of the available space with other columns/rows that also specify *.
In fact * is equivalent to 1*. It is possible to specify 2*, 3* ... N* for a width or height. The algorithm Silverlight uses is to total all values of N for all the rows using * then give each row its appropriate share of the available space. For example:-
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="2*" />
<RowDefinition Height="3*" />
<RowDefinition Height="Auto" />
</Grid.Definitions>
This would first determine how high the forth row needs to be from its content and substract that from the full availabe height. The remainder of height will be divided amoungst the * rows. The first getting 1/6, the second getting a 1/3 and the third getting 1/2 of the available height.
Auto will make the each column size so it can fit whatever is contained in it.
* will use up the maximum amount of available space. It is best to use when you have a "left over" column that you want to just resize to whatever is left over.
Example Grid of width undefined.
Scenario 1:
Column 1 | Column 2 | Column 3
----------------------------------
100 Width | Auto | 200 Width
On this case column 2 could be anything between 1 and whatever the content that is put in it requires and the max space available for the grid's width. If column 2 was changed to * and a width defined on the grid as a whole it would to fill in the left over space to achieve the grid's width. If you had two columns set as *, and a grid width defined, then they would compete for the left over space and split it.
Usually I use * for only one column maximum (although this is not a rule) if I have a control that is set to a dynamic size so that the column will fill in whatever space is left over by the other columns. It's great if you want specific sized columns for a dynamically sized control and want certain columns to stay fixed and define one column to expand to fill in the rest of the control. Auto would not do this with empty or low content columns that would not actually fill the left over space.
Scenario 2 (col 3 contains content that is 100 width and grid has a total width of 800):
Column 1 | Column 2 | Column 3 | Column 4
--------------------------------------------
100 Width | 200 Width | Auto | *
Column 3 would then only size to 100 width. Column 4 would size to 400 width to fill in the left over space.
This page (admittedly from Silverlight 2, but it's still valid) has some examples of using the grid with the following explanations:
For every row in the Grid we have a RowDefinition element. All row definitions are enclosed in a Grid.RowDefinitions element. Our first two rows are 50 pixels high and Height of the third one is set to “*”. This indicates that the row will take the whole place in the Grid which is not taken by the other rows.
and:
Another option is to set the width and/or the height to “auto”. This way every column/row changes its size so as to match the width/height of the controls in it. For example:
Related
I have a pandas.DataFrame which I would like to represent as string (not in Jupyter, not in IPython) with limited width (for later terminal output), without line wrapping (one value per output line) and with ellipses for excess columns in the middle. This is similar what Pandas does when printing to terminal. Is there a function for that? DataFrame.to_string lets me only wrap excess lines (with line_width) but I don't see a way to insert the ellipsis automatically.
If I understand your correctly, you could just do:
print(str(df))
But if you would like to specify n rows and n columns, pd.DataFrame.to_string has arguments for that:
print(df.to_string(max_rows=10, max_cols=10))
This would only display 10 columns (5 columns and ellipsis then another 5 columns), and 10 rows (5 rows and ellipsis then another 5 rows).
I have a column that contains measurements in terms of length and width. Each entry in this column is written in the form lxw. I need to separate this column into two separate columns with one being length and the other being width. Please see below:
This is my original column called "size":
size
930x570
1460x700
4x7
I want to turn "size" into columns "length" and "width" as follows:
length
width
930
570
1460
700
4
7
Use below
select
split(size, 'x')[offset(0)] as length,
split(size, 'x')[offset(1)] as width
from your_table
if applied to sample data in your question - output is
You can use split():
select t.*,
split(size, 'x')[ordinal(1)] as length,
split(size, 'x')[ordinal(2)] as width
from t;
Here is my problem:
Raw data 1
If there is a position 105 and 150, I need the material number of position 150. If there is only position 105, I need the material number of position 105.
On the right side of the picture you can see the correct selected material number.
Now I need to assign this data to position 100 (bc I will use a counter later on, which is depending on position 100).
Here you can see more of the raw data of the report (I can´t insert the complete report here, I use the details area only for testing).
I marked one "group" in which you can see why I can´t change the order of the positions. In this case I need to use position 105 to output the material number (number rightmost on the red border) because there is no position 150.
Raw data 2
Here is another example with position 150 used for the material number (the correct material number will be placed on position 105 every time):
Raw data 3
To use this material number in my following tables, it need to be assigned to position 100.
Thanks!
I would like to position my table by controlling its placement both vertically and horizontally.
I can place it horizontally using the following:
Commodtable.Rows.LeftIndent = "5cm"
How do I do the same but vertically? I know there is verticalalignment but there are only 3 options: Top, Middle and bottom.
This is so i can eventually place 6 tables in a 3 x 2 arrangement.
To get the 3 x 2 arrangement you can add tables to a table.
See this post:
https://stackoverflow.com/a/36304148/162529
Do draw a table at an absolute position you can add the table to a TextFrame object.
But to get the 3 x 2 arrangement, I would probably prefer nested tables.
I am currently working on a Windows 8 Metro/Modern UI application. Right now, I'm working on the interface in Expression Blend for Visual Studio.
My question is this: When sizing UI elements such as grid columns, I can use either pixels, auto, or stars. What is a star in this context? A google search turns up nothing and I haven't found anything in the Windiws 8 developer documentation.
Thank you.
In a grid a * means that it will equally share available space with other * columns (or rows). There are some good WPF examples of how this works here.
From the documentation here:
starSizing
A convention by which you can size rows or columns to take
the remaining available space in a Grid. A star sizing always includes
the asterisk character (), and optionally precedes the asterisk with
an integer value that specifies a weighted factor versus other
possible star sizings (for example, 3). For more information about
star sizing, see Grid.
In a grid with multiple columns, the * size columns divide up the remaining space. For example assume a 300px wide grid with 3 columns (150px, 120px and 1*).
The calculation is:
remainder = (300 - 150 - 120)
Since the remainder is 30px the 1* column is 30px wide
Now add some columns and modify the widths to (35px, 85px, 2*, 1*, 3*)
Redoing the calculation:
remainder = (300 - 35 - 85)
In this scenario the remainder is 180px, so each * column splits the remaining pixels according to their weighting number.
factor = (180/ (2 + 1 + 3))
factor = 30px
Therefore the 2* column is 60px, the 1* column is 30px and the 3* column is 90px
300 == 35 + 85 + 60 + 30 + 90
Of course the same principles apply for Row sizing.
When the grid is resized the * columns divvy up the new remainder size. But they keep the same size ratio between other * size items. In the example the 3* column will always be 3 times as wide as the 1* column.