我正在尝试在 listView 中获取多行我目前有以下 XAML:
<ListView x:Name="listTasks" Margin="0,0,1.5,0" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0" Foreground="White" ItemsSource="{Binding TasksCollection}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Background"
Value="{x:Null}" />
<Setter Property="BorderBrush"
Value="{x:Null}" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="{x:Null}" />
<Setter Property="BorderBrush"
Value="{x:Null}" />
</Trigger>
</Style.Triggers>
<Setter Property="Height" Value="50px" />
<Setter Property="Focusable" Value="false" />
</Style>
</ListView.ItemContainerStyle>
<ListView.Resources>
<Style x:Key="CustomHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</ListView.Resources>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{DynamicResource CustomHeaderStyle}">
<GridViewColumn Header="">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat=" Module: {0} Conditions: {1}|{2}|{3} for {4} minutes">
<Binding Path="Module"/>
<Binding Path="FirstValue"/>
<Binding Path="SecondValue"/>
<Binding Path="ThirdValue"/>
<Binding Path="Minutes"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
这会输出如下内容:
我想要实现的是这样的(忽略不同颜色的背景):
我似乎无法思考如何做到这一点,有什么想法吗?
谢谢