Question

I have populated a datagrid in WPF but i dont know its generating buttons type thing on left hand side of grid, i want to remove it, how i can remove it, any idea?

Here is screen shot :

enter image description here

Here is my xaml code:

        <DataGrid Name="Patients" SelectedValuePath="patientid" CanUserResizeRows="False"   Background="#942E2A" GridLinesVisibility="None" HorizontalGridLinesBrush="#73261E" BorderBrush="#73261E" BorderThickness="5"  SelectionChanged="Patients_SelectionChanged" ItemsSource="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" AutoGenerateColumns="False" Height="400" Width="340">

            <DataGrid.Resources>
                <Style TargetType="{x:Type DataGridColumnHeader}">
                    <Setter Property="Background" Value="#942E2A" />
                    <Setter Property="FontSize" Value="18" />
                    <Setter Property="Width" Value="150" />
                    <Setter Property="FontFamily" Value="Georgia" />
                    <Setter Property="Foreground" Value="White" />
                    <Setter Property="FontWeight" Value="Bold" />
                </Style>
                <Style TargetType="DataGridRow">
                    <Setter Property="Background" Value="#942E2A" />
                    <Setter Property="FontSize" Value="14" />
                    <Setter Property="FontFamily" Value="Georgia" />
                    <Setter Property="Foreground" Value="White" />

                    <Style.Triggers>
                        <Trigger Property="IsSelected"
                Value="True">
                            <Setter Property="BorderBrush"
                Value="White" />
                            <Setter Property="BorderThickness"
                Value="2" />
                            <Setter Property="Background"
                Value="White" />
                            <Setter Property="Foreground" Value="Black"></Setter>
                        </Trigger>
                    </Style.Triggers>

                </Style>
            </DataGrid.Resources>

            <DataGrid.Columns>

                <DataGridTemplateColumn Header="Patient ID" SortMemberPath="patientid" Width="Auto" MinWidth="100" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.Style>
                                    <Style>

                                    </Style>
                                </Grid.Style>

                                <TextBlock Text="{Binding Path=patientid}">
                                </TextBlock>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Last, First" SortMemberPath="name" Width="Auto" MinWidth="100" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.Style>
                                    <Style>

                                    </Style>
                                </Grid.Style>
                                <TextBlock Text="{Binding Path=name}"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

            </DataGrid.Columns>

        </DataGrid>
Was it helpful?

Solution

A bit strange but rows have a Header. That's what you see. Setting the visibility of the column header only will solve your Problem:

HeadersVisibility="Column"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top