0
誰能可能是爲了我解釋爲什麼下面的簡單示例工程:如何獲取在ItemsControl中工作的WPF GridSplitter控件?
<ItemsControl x:Class="UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="5" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Background="Yellow" />
<GridSplitter Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
<Grid Grid.Row="2"
Background="Orange" />
</Grid>
</ItemsControl>
...但是當我做ItemsPanelTemplate的主要原因之一,這不:
<ItemsControl x:Class="UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="5" />
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<Grid Background="Yellow" />
<GridSplitter Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
<Grid Grid.Row="2" Background="Orange" />
</ItemsControl>
他們都顯示器橙色盒子頂部的黃色盒子,它們之間有水平分配器。在第一個例子中,分離器工作正常,可以調整兩個區域的大小。在第二個例子中(產生一個幾乎相同的視覺樹),分離器被鎖定,它不會讓我拖動它來調整兩個區域的大小!
這是我試圖實現的一個非常簡單的例子 - 但它演示了我在實際應用程序中遇到的問題。我必須錯過一些東西,阻礙分離器運作的是什麼?所有三個孩子被添加到ItemsPanelTemplate網格確定....
任何解釋或修復將不勝感激!
問候, 戴夫