Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am presenting a number of items (text only) in a ListView with a GridView of five columns. The background color of each line is bound to a color name reflecting the state of the item. Like this:

XML
<ListView  Name="viewInst"
  Padding="0" Margin="0,10,0,5" 
  HorizontalContentAlignment="Stretch" 
  HorizontalAlignment="Stretch"
  ItemsSource="{Binding guiInstSet}">

  <ListView.View>
    <GridView>
      <GridView.Columns>

        <GridViewColumn Header="Installer" Width="300" >
          <GridViewColumn.CellTemplate>
            <DataTemplate>
              <TextBox Width="200"
                Margin="0" Padding="0,2" BorderThickness="0" 
                Background="{Binding bgcol}" 
                Text="{Binding installerName}" />
            </DataTemplate>
         </GridViewColumn.CellTemplate>
      </GridViewColumn>


... followed by four more similar GridViewColumn definitions.

I would like each item to appear as one line in the table, but between the fields are the column separators, breaking up the line with white space (or rather: The Background of the ListView).

I have searched - with no success yet - for either ways to set the width of this column separator to zero, or (preferably) to set the background color to the same color as the cells on the line. Note that setting a (single) background color for the entire column separator is not what I want; the color changes from line to line.

Any hint about what to search for to make the lines appear as lines, rather than a row of disjunct cells, will be highly appreciated!
Posted

1 solution

I'm not sure, but try this

XML
<datatemplate>
    <border borderthickness="0,0,0,0" background="{Binding bgcol}" borderbrush="{Binding bgcol}">
        <textblock margin="2" text="{Binding installerName}" />
    </border>
</datatemplate>
 
Share this answer
 
Comments
trønderen 7-Nov-12 10:35am    
Sorry, that didn't make much difference. At least not on the column separators.

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