Note that there are some explanatory texts on larger screens.

plurals
  1. POIs WPF StackPanel freezable
    primarykey
    data
    text
    <p>I'm using <code>StackPanel</code> in WPF just for easy layouting horizontally aligned boxes and lines, but it seems the performance of application is getting slower when using <code>StackPanel</code>.</p> <p>All the Microsoft tutorials seems to talk only about freezing some <code>SolidColorBrush</code> etc. objects, but can StackPanel be freezed after first layout so the CPU doesn't have to layout it all the time, just once?</p> <p>Or am I just forced to use the very fast <code>Canvas</code> object and layout all the objects inside it one by one?</p> <p>Example 1: Very easy to layout in designer, but lacks performance:</p> <pre><code> &lt;StackPanel Height="35" Canvas.Left="49" Canvas.Top="874" Width="395" Orientation="Horizontal"&gt; &lt;TextBox Text="test" Width="65"/&gt; &lt;Rectangle Stroke="Black" Width="1" /&gt; &lt;TextBox Text="test" Width="55"/&gt; &lt;Rectangle Stroke="Black" Width="1" /&gt; &lt;TextBox Text="test" Width="75"/&gt; &lt;Rectangle Stroke="Black" Width="1" /&gt; &lt;TextBox Text="test" Width="35"/&gt; &lt;Rectangle Stroke="Black" Width="1" /&gt; &lt;TextBox Text="test" Width="95"/&gt; &lt;Rectangle Stroke="Black" Width="1" /&gt; &lt;TextBox Text="test" Width="65"/&gt; &lt;Rectangle Stroke="Black" Width="1" /&gt; &lt;/StackPanel&gt; </code></pre> <p>Example 2: Good performance, making layout in designer is a pain:</p> <pre><code> &lt;Canvas Height="35" Canvas.Left="49" Canvas.Top="914" Width="395"&gt; &lt;TextBox Text="test" Width="65" Height="35"/&gt; &lt;Rectangle Stroke="Black" Width="1" Height="35" Canvas.Left="65"/&gt; &lt;TextBox Text="test" Width="55" Canvas.Left="66" Height="35"/&gt; &lt;Rectangle Stroke="Black" Width="1" Height="35" Canvas.Left="195"/&gt; &lt;TextBox Text="test" Width="75" Height="35" Canvas.Left="122"/&gt; &lt;Rectangle Stroke="Black" Width="1" Height="35" Canvas.Left="121"/&gt; &lt;TextBox Text="test" Width="35" Height="35" Canvas.Left="198"/&gt; &lt;Rectangle Stroke="Black" Width="1" Height="35" Canvas.Left="197"/&gt; &lt;TextBox Text="test" Width="95" Height="35" Canvas.Left="234"/&gt; &lt;Rectangle Stroke="Black" Width="1" Height="35" Canvas.Left="329"/&gt; &lt;TextBox Text="test" Width="65" Height="35" Canvas.Left="330"/&gt; &lt;Rectangle Stroke="Black" Width="1" Height="35" Canvas.Left="233"/&gt; &lt;/Canvas&gt; </code></pre>
    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.
 

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