Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In this case you are using the canvas coordinates to give 87 spacing on the left and 22 spacing between tops of elements. The StackPanel is already laying out the items one after another. You just need to set the margins for your textblocks</p> <pre><code> &lt;StackPanel&gt; &lt;StackPanel.Resources&gt; &lt;Style TargetType="{x:Type TextBlock}"&gt; &lt;Setter Property="Foreground" Value="Red"&gt;&lt;/Setter&gt; &lt;Setter Property="FontFamily" Value="Arial"&gt;&lt;/Setter&gt; &lt;Setter Property="FontSize" Value="14" /&gt; &lt;Setter Property="Margin" Value="87,4, 0, 4" /&gt; &lt;/Style&gt; &lt;/StackPanel.Resources&gt; &lt;TextBlock&gt;mytext1&lt;/TextBlock&gt; &lt;TextBlock&gt;mytext2&lt;/TextBlock&gt; &lt;TextBlock&gt;mytext3&lt;/TextBlock&gt; &lt;/StackPanel&gt; </code></pre> <p>To answer your question you can use a Grid control (or Canvas or any other element) wherever you wish to isolate a Resources section. Grid does not perform any layout.</p> <pre><code>&lt;StackPanel&gt; &lt;StackPanel.Resources&gt; &lt;Style TargetType="{x:Type TextBlock}"&gt; &lt;Setter Property="Foreground" Value="White"&gt;&lt;/Setter&gt; &lt;Setter Property="FontFamily" Value="Arial"&gt;&lt;/Setter&gt; &lt;/Style&gt; &lt;/StackPanel.Resources&gt; &lt;TextBlock&gt; mytext1 &lt;/TextBlock&gt; &lt;Canvas&gt; &lt;Canvas.Resources&gt; &lt;Style TargetType="{x:Type TextBlock}"&gt; &lt;Setter Property="Foreground" Value="Red"&gt;&lt;/Setter&gt; &lt;Setter Property="FontFamily" Value="Times"&gt;&lt;/Setter&gt; &lt;/Style&gt; &lt;/Canvas.Resources&gt; &lt;TextBlock Canvas.Left="87" Canvas.Top="210"&gt;mytext2&lt;/TextBlock&gt; &lt;TextBlock Canvas.Left="87" Canvas.Top="232"&gt;mytext2&lt;/TextBlock&gt; &lt;/Canvas&gt; &lt;/StackPanel&gt; </code></pre>
    singulars
    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.
    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