なぜDockPanel.Dock =“ Bottom”要素を上部に配置しますか?
質問
次のコードは、2番目のテキスト要素が「Bottom」とマークされていても、2つのテキスト要素を上部に配置します。背景色は一番下まで行くので、DockPanelは一番下まで伸びているようです。
DockPanelについて理解できないことは何ですか?
<Window x:Class="TestIndexer934.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:TestIndexer934.Commands"
Title="Main Window" Height="400" Width="800">
<DockPanel HorizontalAlignment="Left" Background="Beige">
<TextBlock DockPanel.Dock="Top" Text="Testing top"/>
<TextBlock DockPanel.Dock="Bottom" Text="Testing bottom"/>
</DockPanel>
</Window>
解決
default によってDockPanelの最後のアイテム残りの利用可能なコンテンツ領域が埋められます。
DockPanelで LastChildFill =&quot; False&quot;
を設定すると、予想される動作が表示されます。 TextBlockで VerticalAlignment =&quot; Bottom&quot;
を設定することもできます。
所属していません StackOverflow