Highlighting Row

Feb 12, 2009 at 11:47 PM

I have built a Datagrid with multiple columns and several of those columns use DataTemplates which is great, I have also centered my text vertically in the cell.  My problem is when I selected a row the cells that use the DataTemplates are a little taller than the other cells and the blue highlight does not shade the non template cells correctly.  My data templates are located below along with a normal text column that is vertically aligned

<wpftk:DataGridTemplateColumn MinWidth="150" Header="Status" x:Name="statusHeader" SortMemberPath="Status.Description"  Width="Auto">
                    <wpftk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Style="{StaticResource NoBorderButton}" x:Name="statusButton" Grid.Column="0" MinWidth="100" Tag="{Binding}" Click="StatusDropDown_Click" Foreground="{Binding Path=Status.ForeColor, Converter={StaticResource ColorConverter}}"
                                    Background="{Binding Path=Status.BackColor, Converter={StaticResource ColorConverter}, ConverterParameter=true}"
                                    HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Margin="0,1,0,1">
                                <Border Margin="0,1.5" Background="{Binding Path=Status.BackColor, Converter={StaticResource ColorConverter}, ConverterParameter=true}" BorderBrush="{Binding Path=Status.BackColor, Converter={StaticResource ColorConverter}, ConverterParameter=true}" BorderThickness="1" CornerRadius="6">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Margin="3,0" Text="{Binding Status.Description}" HorizontalAlignment="Stretch"  TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>
                                        <Polygon x:Name="dropPolygon" Grid.Column="1" Margin="3,0"  Points="0,0 7.5,7.5 15,0" Fill="{Binding Path=Status, Converter={StaticResource dropColor}}" HorizontalAlignment="Center" VerticalAlignment="Center"
                                         Visibility="{Binding Converter={StaticResource statusToVis}}"/>
                                    </Grid>
                                </Border>
                            </Button>
                        </DataTemplate>
                    </wpftk:DataGridTemplateColumn.CellTemplate>
                </wpftk:DataGridTemplateColumn>

<wpftk:DataGridTextColumn Header="Age" Binding="{Binding Path=Patient.Age, Mode=OneWay}" IsReadOnly="True"  Width="Auto">
                    <wpftk:DataGridTextColumn.CellStyle>
                        <Style TargetType="{x:Type wpftk:DataGridCell}" >
                            <Setter Property="TextBlock.TextAlignment" Value="Right" />
                            <Setter Property="TextBlock.VerticalAlignment" Value="Center"/>
                        </Style>
                    </wpftk:DataGridTextColumn.CellStyle>
                </wpftk:DataGridTextColumn>

I guess my question is how do I get the cells to be vertically aligned correctly or how do I get the highlight to shade correctly?

Thanks for any help.