谁能向我解释为什么下面的简单示例有效:
<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>
Run Code Online (Sandbox Code Playgroud)
...但是当我将 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>
Run Code Online (Sandbox Code Playgroud)
它们都在橙色框的顶部显示一个黄色框,它们之间有一个水平分隔线。在第一个示例中,分割器工作正常,允许您调整两个区域的大小。在第二个示例中(生成几乎相同的视觉树),分割器被锁定,它不允许我拖动它来调整两个区域的大小!
这是我想要实现的目标的一个非常简单的示例 - 但它演示了我在实际应用程序中遇到的问题。我一定错过了一些东西,是什么阻止了分离器的功能?所有三个子项都添加到 ItemsPanelTemplate 网格中,确定......
任何解释或修复将不胜感激!
问候,戴夫
| 归档时间: |
|
| 查看次数: |
1531 次 |
| 最近记录: |