Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - ListView column backgrounds

 
 
Old 06-14-2007   #1 (permalink)
Grafix


 
 

ListView column backgrounds

All -
I want to have a different background for a specific column in ListView.
For instance a sorted column's background / a third column's background etc)

I tried to specify a CellTemplate on the GridViewColumn node, but i have
run into problems:
Ex:
<GridViewColumn Header="MySpecialColumn" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid Background="Orange" HorizontalAlignment="Stretch">
<TextBlock Padding="2" Text="{Binding XPath=@Subject}"/>
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

Q1:
I am not specifying the width of the GridViewColumn explicitly (so the
column will size to fit the content).
Hence the cell background for each row fits the content background only.
For instance the 1st row of my target column has text as "hi" and the second
row has "World" - the background "Orange" is getting applied only for the
length of the text (hence its short for hi and a bit long for "World".)
This is inspite of setting HorizontalAlignment to stretch for the Grid.

How to make the grid width span the entire GridViewColumn width?

Q2:
I tried to set a dynamic binding of the width of the Grid to the width of
the GridViewColumn. How to specify the binding here?

I am not able to use RelativeSource - FindAncestor - since GridViewColumn is
not on the visual tree of the grid. TemplatedParent gives me the ListView
which i dont want.

So - from the UIElement "Grid" inside the DataTemplate node - how to
reference a property of "GridViewColumn" like Width for binding?

Please note that the binding worked with specifying ElementName and
explicitly specifying a name for the GridViewColumn - but i dont want to do
this.

Thanks in advance.

Regardz
Grafix.






My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Re: backgrounds Vista file management
Is it possible in "computer" to view files from top to bottom in 1st column then same again in next column to the right etc? Vista file management
different backgrounds Vista General
BACKGROUNDS Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46