0

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>

これは次のようなものを出力します:

ここに画像の説明を入力してください

私が達成しようとしているのは、次のようなものです(異なる色の背景は無視してください)。

ここに画像の説明を入力してください

私はこれをどのように行うかについて頭を悩ませているようには見えません、何かアイデアはありますか?

ありがとう

4

1 に答える 1

1

StackPanel一連のTextBlock要素を別の要素の上に配置するために、垂直方向を使用できます。

<DataTemplate>
   <StackPanel>
      <TextBlock Text="{Binding Module, StringFormat='Module: {0}'}"/>
      <TextBlock Text="{Binding FirstValue, StringFormat='Module: {0}'}"/>
      ...
   </StackPanel>
</DataTemplate>

または、すべてを1つの`TextBlock'でフォーマットできます。

<DataTemplate>
   <TextBlock>
      <Run Text="Module: "/><Run Text="{Binding Module}"/><LineBreak/><Run Text="Conditions: "/><Run Text="{Binding FirstValue}"/><LineBreak/>
      ...
   </TextBlock>
</DataTemplate>
于 2012-05-20T13:27:47.077 に答える