Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In my multi column ListView I have certain rows with a very large text in the first column, but no text in all the following columns (I call them "HeaderRows") and below I have some rows where all columns are filled with some short textural information.

My problem is, that the first column of all the HeaderRows is clipped.

In Excel there is a solution that only populated cells will clip the content of the cell on it's left side.

Does anyone have an idea how such a behaviour can be achieved with a ListView?

Thanks in advance and greetings from germany,

Helmut
Posted

1 solution

If you're doing it with a GridView, I don't know of a solution to that little issue...

But if you delve into the ItemTemplate and handle the columns yourself, you might be able to hack something like that in...
XML
<ListView.ItemTemplate>
  <DataTemplate DataType="...">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" SharedSizeGroup="..."/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <TextBlock Grid.Column="0" Text="{Binding col0Text}"
                 Grid.ColumnSpan="{Binding col1Text,Converter={StaticResource cnvOneOrTwo}"
      />
      <TextBlock Grid.Column="1" Text="{Binding col1Text}"/>
      <TextBlock Grid.Column="2" Text="{Binding col2Text}"/>
    </Grid>
  </DataTemplate>
</ListView.ItemTemplate>

(Note: Code entered here, so not tested/debugged)

Basically, create a custom IValueConverter that would take the contents of the NEXT column as an argument, and return 1 if it's populated or 2 if it's empty. You could even pass the entire bound record, and have your converter check each column for data and determine the correct ColumnSpan.

It's not a one-line solution, but it might do the trick.
 
Share this answer
 
Comments
HelmutBerg 23-Sep-11 7:21am    
Hi Ian,

thanks for your response! Unfortunately I have to stick with the multi column ListView, I guess. To be more precise: In fact I use the TreeList introduced by Andrey Gliznetsov here in this forum, which itself uses the ListView as baseclass (I did not want to make it too complicated in my first question) I do not think that I can change this sample easily to support a standard grid.

Greetings

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900