tags:

views:

21

answers:

1

I have a set of data that I'd like to present via a WPF ListView in this way:

Column1   Column2   Column3
--GroupName1--
Item1     part2     part3
Item2     part2     part3
--GroupName2--
Item3     part2     part3
Item4     long_text_in_both_columns
Item5     part2     part3
--GroupName1--
Item6     part2     part3
Item7     long_text_in_both_columns
--GroupName3--
Item8     part2     part3

I am starting by working with this basic sample: http://msdn.microsoft.com/en-us/library/ms771309(VS.90).aspx

Item4 and Item7 above have long text that I would like to span the remaining columns (ignoring what the original column headings were for). How can I do this?

I already have some XAML setup with a DataTrigger to replace the default GridViewRowPresenter with a custom TextBlock, but this isn't quite what I'm looking for. I need the data in column 1 to be displayed normally and the width of the first column recognized.

A: 

I think for this, you use ListBox instead of ListView and use its ItemTemplate to split each columns.

<ListBox>
<ListBox.ItemTemplate>
 <DataTemplate>
  <StackPanel>
    <TextBlock Text="{Binding Text1}"/>
    <TextBlock Text="{Binding Text2}" />
  </StackPanel>
 </DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

In this way you will have chance to put Trigger in or based on some data, you could make one control invisible and show the long text.

:)

abhishek
Do I still get the other benefits of using a ListView, such as columns that all line up and are resizable?
PeteVasi
No, you dont. But you need to implement the same yourself. May be you can bind the size of each TextBlock with the size of header, so that when header is resized, the size of each TextBox changes.
abhishek