垂直和水平
<pre><code class="language-csharp">&lt;!--垂直--&gt;
&lt;!--&lt;StackPanel&gt;
&lt;Button Content=&quot;1&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;2&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;3&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;4&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;5&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;6&quot;&gt;&lt;/Button&gt;
&lt;/StackPanel&gt;--&gt;
&lt;!--水平--&gt;
&lt;!--&lt;StackPanel Orientation=&quot;Horizontal&quot;&gt;
&lt;Button Content=&quot;1&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;2&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;3&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;4&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;5&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;6&quot;&gt;&lt;/Button&gt;
&lt;/StackPanel&gt;--&gt;
&lt;StackPanel Orientation=&quot;Vertical&quot;&gt;
&lt;Button HorizontalAlignment=&quot;Center&quot; Content=&quot;1&quot;&gt;&lt;/Button&gt;
&lt;Button VerticalAlignment=&quot;Center&quot; Content=&quot;2&quot;&gt;&lt;/Button&gt;
&lt;Button Height=&quot;50&quot; Content=&quot;3&quot;&gt;&lt;/Button&gt;
&lt;Button Width=&quot;200&quot; Content=&quot;4&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;5&quot; Margin=&quot;10 15&quot;&gt;&lt;/Button&gt;
&lt;Button Content=&quot;6&quot;&gt;&lt;/Button&gt;
&lt;/StackPanel&gt;</code></pre>