我在网格中有动态数量的元素并使用模板进行可视化:
<UserControl x:Class="MUSTANG.GUI.TableModule.Controls.ColumnAxis"
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"
mc:Ignorable="d" >
<UserControl.Resources>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<!-- Here will be the layout of the elements from the ListView -->
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="ListView">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=TreeItemChildren.Count}" Value="0">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<ListView ItemsSource="{Binding Path=RootItem.TreeItemChildren}" Padding="{Binding Path=RootItem.PaddingFixWindows6}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<!-- Somewhere here should be a GridSplitter -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
</StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
</UserControl>
现在我想为 ListView 中的每个项目使用一个 GridSplitter。我试过的任何东西都不起作用,因为 ItemsPanelTemplate 只需要一个 VisualTree(所以我不能在 StackPanel 下面放一个 Gridsplitter)。
有没有可能以另一种方式做到这一点?也许来自代码隐藏文件?我需要解决我有动态数量的元素并且我想在它们之间使用某种拆分器的主要问题。
背景信息:由于递归调用,我必须使用模板。在第一个网格之后的原始代码中是另一个 ListView。