14
以下代碼將兩個文本元素置於頂部,即使第二個文本元素標記爲「底部」。背景顏色一直到底部,所以DockPanel似乎延伸到底部。爲什麼DockPanel.Dock =「Bottom」將元素放在頂部?
我對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>
很可能是這裏的情況。請參閱:http://msdn.microsoft.com/en-us/library/system.windows.controls.dockpanel.lastchildfill.aspx – 2009-06-17 08:05:22