1
我有簡單的WPF UserControl,如下所示。WPF:DockPanel中的兩個控件停靠在「頂部」和「底部」仍然留下底部空間
我不明白爲什麼這個代碼犯規針綠色網格的DockPanel中的底部:
如果我在兩個塊之間添加的東西,那麼綠色被固定在底部:
下面是簡單的代碼:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:tWorks.Alfa.OperatorClient.UserControls.Vehicles"
xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" x:Class="tWorks.Alfa.OperatorClient.UserControls.Vehicles.Misc_Vehicles_GpsTrackBarContext"
mc:Ignorable="d"
d:DesignHeight="260" d:DesignWidth="450">
<DockPanel>
<Grid DockPanel.Dock="Top" Height="50" Background="Red"></Grid>
<Grid DockPanel.Dock="Bottom" Height="50" Background="Green"></Grid>
<Grid Height="50" Background="Blue"></Grid>
</DockPanel>
感謝=)
謝謝!這是一個非常奇怪的行爲。這是什麼原因,人們可能會懷疑......無意義=) – Ted
「原因」是一個很大的詞,但是如果WPF開發者確實允許'DockPanel.Dock =「Fill」',那麼我很樂意。不需要將填充元素放在最後,並將默認的Tab鍵排序,等等......我無法給出一個理由,只知道我自己很難學會,所以現在它相對容易回答其他問題: ) – grek40