Note that there are some explanatory texts on larger screens.

plurals
  1. POXAML: UniformGrid where you can define cells as not unifrom in size?
    primarykey
    data
    text
    <p>As a part of an <code>ItemsControl</code> style I'd like to have something that works similar ot <code>Grid/UniformGrid</code> as an <code>ItemsPanel</code>.</p> <p>In its simplest form, the <code>Style</code> would look like this:</p> <pre><code>&lt;Style TargetType="{x:Type ItemsControl}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate&gt; &lt;ItemsPresenter /&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="ItemsPanel"&gt; &lt;Setter.Value&gt; &lt;ItemsPanelTemplate&gt; &lt;UniformGrid Columns="2" /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="ItemContainerStyle"&gt; &lt;Setter.Value&gt; &lt;Style&gt; &lt;Setter Property="Control.Margin" Value="10"/&gt; &lt;/Style&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>and I would use it like this:</p> <pre><code>&lt;WrapPanel Orientation="Vertical"&gt; &lt;ItemsControl&gt; &lt;TextBlock Text="Label1:"/&gt; &lt;TextBlock Text="ThisWillBeBound" /&gt; &lt;/ItemsControl&gt; &lt;ItemsControl&gt; &lt;TextBlock Text="Label2:"/&gt; &lt;TextBlock Text="ThisWillBeBound" /&gt; &lt;/ItemsControl&gt; &lt;ItemsControl&gt; &lt;TextBlock Text="Label3:"/&gt; &lt;TextBlock Text="ThisWillBeBound" /&gt; &lt;/ItemsControl&gt; &lt;ItemsControl&gt; &lt;TextBlock Text="Label4:"/&gt; &lt;TextBlock Text="ThisWillBeBoundButIsSomewhatLongerThenTheOtherProperties" /&gt; &lt;/ItemsControl&gt; &lt;ItemsControl&gt; &lt;TextBlock Text="Label5:"/&gt; &lt;TextBlock Text="ThisWillBeBound" /&gt; &lt;/ItemsControl&gt; &lt;ItemsControl&gt; &lt;TextBlock Text="Label6:"/&gt; &lt;TextBlock Text="ThisWillBeBound" /&gt; &lt;/ItemsControl&gt; &lt;/WrapPanel&gt; </code></pre> <p>As you can see, you would throw a <code>Label</code> for a property into this plus a binding to that property and they would stick together even if things would wrap around becuase of different sizes of the app window for example.</p> <p>The nice thing here about the<code>UniformGrid</code> is that it seems that if one <code>Label</code> is longer the others will get the same space meaning the bound properties would line up neatly (why this happens I don't understand because these should be seperate <code>UniformGrid</code>s I guess). Problem here is that the cell width of the <code>Label</code> part and the <code>Property</code> part is the same, so if the property is long there will be a large gap between the <code>Label</code> and the <code>Property</code>.</p> <p>Using normal <code>Grid</code> instead would mean I'd have to set the <code>Grid.Column="0"</code> and <code>Grid.Column="1"</code> everyplace I put items into this <code>ItemsControl</code>. That's not really what I wan't.</p> <p>Is there a way for me to have some sort of grid that lines up like the uniform one but doesn't stratch all columns when one only needs to be and assumes you are putting into columns the same way you declare the items?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload