I'm using a CellTemplateSelector to change the cell background color of specific cells with specific values. However, I can't get the cell background color to fill the cell; it hugs the content. Here's my markup:
<DataTemplate x:Key="Template1"> <Grid Background="#C0D9AF"> <TextBlock Text="{Binding Path=Value}" /> </Grid> </DataTemplate> <DataTemplate x:Key="Template2"> <Grid Background="#FFFCCF"> <TextBlock Text="{Binding Path=Value}" /> </Grid> </DataTemplate>
And my code:
private class CellTemplateSelector : DataTemplateSelector { public override DataTemplate SelectTemplate(object item, DependencyObject container) { return ((FrameworkElement)container).FindResource(condition ? "Template1" : "Template2") as DataTemplate; } }