How to set back color of table of columns in wpf?

I have a wpf mvvm application. And have a GRID with multiple columns

What is the best way to set the background in the grid column in wpf?

+4
source share
2 answers

One of the methods:

Create a rectangle and set its fill to the color of your choice.
Then set its Grid.RowSpan value to the large number or number of rows you have.

+2
source

dabble125's answer was perfect, but to give you a sample and mention a note about what matters, where to place the rectangle, see code:

<Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <!-- this is not a good place for text block. the text block is beneath the rectangle so it would not be seen --> <!--<TextBlock Grid.Column="1" Text="Some Text"/>--> <Rectangle Grid.Column="1" Grid.RowSpan="1000"> <Rectangle.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF83FF97" Offset="0" /> <GradientStop Color="White" Offset="1" /> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <TextBlock Grid.Column="1" Text="Some Text"/> </Grid> 
+11
source

All Articles